Merge commit 'fd4957d9c67996e7d218fd36b4168c9cb85f9ea7'

* commit 'fd4957d9c67996e7d218fd36b4168c9cb85f9ea7':
  movenc-test: Test write_data_type

Merged-by: Matthieu Bouron <matthieu.bouron@stupeflix.com>
This commit is contained in:
Matthieu Bouron 2016-06-23 18:03:49 +02:00
commit d671652f6e
2 changed files with 145 additions and 1 deletions

View File

@ -69,6 +69,7 @@ enum AVPictureType last_picture;
int skip_write;
int skip_write_audio;
int clear_duration;
int force_iobuf_size;
int num_warnings;
@ -101,6 +102,35 @@ static int io_write(void *opaque, uint8_t *buf, int size)
return size;
}
static int io_write_data_type(void *opaque, uint8_t *buf, int size,
enum AVIODataMarkerType type, int64_t time)
{
char timebuf[30], content[5] = { 0 };
const char *str;
switch (type) {
case AVIO_DATA_MARKER_HEADER: str = "header"; break;
case AVIO_DATA_MARKER_SYNC_POINT: str = "sync"; break;
case AVIO_DATA_MARKER_BOUNDARY_POINT: str = "boundary"; break;
case AVIO_DATA_MARKER_UNKNOWN: str = "unknown"; break;
case AVIO_DATA_MARKER_TRAILER: str = "trailer"; break;
}
if (time == AV_NOPTS_VALUE)
snprintf(timebuf, sizeof(timebuf), "nopts");
else
snprintf(timebuf, sizeof(timebuf), "%"PRId64, time);
// There can be multiple header/trailer callbacks, only log the box type
// for header at out_size == 0
if (type != AVIO_DATA_MARKER_UNKNOWN &&
type != AVIO_DATA_MARKER_TRAILER &&
(type != AVIO_DATA_MARKER_HEADER || out_size == 0) &&
size >= 8)
memcpy(content, &buf[4], 4);
else
snprintf(content, sizeof(content), "-");
printf("write_data len %d, time %s, type %s atom %s\n", size, timebuf, str, content);
return io_write(opaque, buf, size);
}
static void init_out(const char *name)
{
char buf[100];
@ -145,15 +175,17 @@ static void check_func(int value, int line, const char *msg, ...)
static void init_fps(int bf, int audio_preroll, int fps)
{
AVStream *st;
int iobuf_size = force_iobuf_size ? force_iobuf_size : sizeof(iobuf);
ctx = avformat_alloc_context();
if (!ctx)
exit(1);
ctx->oformat = av_guess_format(format, NULL, NULL);
if (!ctx->oformat)
exit(1);
ctx->pb = avio_alloc_context(iobuf, sizeof(iobuf), AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL);
ctx->pb = avio_alloc_context(iobuf, iobuf_size, AVIO_FLAG_WRITE, NULL, NULL, io_write, NULL);
if (!ctx->pb)
exit(1);
ctx->pb->write_data_type = io_write_data_type;
ctx->flags |= AVFMT_FLAG_BITEXACT;
st = avformat_new_stream(ctx, NULL);
@ -670,6 +702,17 @@ int main(int argc, char **argv)
reset_count_warnings();
check(num_warnings > 0, "No warnings printed for filled in durations");
// Test with an IO buffer size that is too small to hold a full fragment;
// this will cause write_data_type to be called with the type unknown.
force_iobuf_size = 1500;
init_out("large_frag");
av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0);
init_fps(1, 1, 3);
mux_gops(2);
finish();
close_out();
force_iobuf_size = 0;
av_free(md5);
return check_faults > 0 ? 1 : 0;

View File

@ -1,28 +1,129 @@
write_data len 36, time nopts, type header atom ftyp
write_data len 2335, time nopts, type header atom -
write_data len 788, time 1000000, type sync atom moof
write_data len 110, time nopts, type trailer atom -
214242e9c7c93171d2f47f5b47776559 3269 non-empty-moov
write_data len 36, time nopts, type header atom ftyp
write_data len 2667, time nopts, type header atom -
write_data len 908, time 966667, type sync atom moof
write_data len 110, time nopts, type trailer atom -
44467d568a3cc38d414fd8ed4b2a968f 3721 non-empty-moov-elst
write_data len 36, time nopts, type header atom ftyp
write_data len 2575, time nopts, type header atom -
write_data len 908, time 1000000, type sync atom moof
write_data len 110, time nopts, type trailer atom -
de22b98a3885f9b4b83cdd48ff46aeb9 3629 non-empty-moov-no-elst
write_data len 20, time nopts, type header atom ftyp
write_data len 1171, time nopts, type header atom -
write_data len 728, time 0, type sync atom moof
write_data len 828, time nopts, type unknown atom -
write_data len 728, time 1013106, type sync atom moof
write_data len 812, time nopts, type unknown atom -
write_data len 148, time nopts, type trailer atom -
1f37c1a8e01651e8bebcd66f00b6a226 4435 ismv
write_data len 36, time nopts, type header atom ftyp
write_data len 1123, time nopts, type header atom -
write_data len 796, time 0, type sync atom moof
write_data len 788, time 1000000, type sync atom moof
write_data len 148, time nopts, type trailer atom -
ed8506ebfce4c41732205ae26a4759fd 2891 empty-moov
write_data len 36, time nopts, type header atom ftyp
write_data len 1123, time nopts, type header atom -
write_data len 1068, time 0, type sync atom moof
write_data len 908, time 1000000, type sync atom moof
write_data len 148, time nopts, type trailer atom -
1844ee6d19fd1e6daf2655632cf26310 3283 empty-moov-no-elst
write_data len 36, time nopts, type header atom ftyp
write_data len 1123, time nopts, type header atom -
write_data len 900, time -33333, type sync atom moof
write_data len 908, time 966667, type sync atom moof
write_data len 148, time nopts, type trailer atom -
139b27dbe2a80c2dc088d0c755f26033 3115 empty-moov-no-elst-no-adjust
write_data len 1159, time nopts, type header atom ftyp
write_data len 796, time 0, type sync atom moof
write_data len 788, time 1000000, type sync atom moof
write_data len 148, time nopts, type trailer atom -
ed8506ebfce4c41732205ae26a4759fd 2891 delay-moov
write_data len 1231, time nopts, type header atom ftyp
write_data len 916, time -33333, type sync atom moof
write_data len 908, time 966667, type sync atom moof
write_data len 148, time nopts, type trailer atom -
3ece148745cd64b4428530a4d1080a2d 3203 delay-moov-elst
write_data len 1195, time nopts, type header atom ftyp
write_data len 836, time 0, type sync atom moof
write_data len 67, time nopts, type trailer atom -
9562946a369e6fb570fb2fd7aa2fe728 2098 delay-moov-empty-track
write_data len 1195, time nopts, type header atom ftyp
write_data len 360, time 0, type sync atom moof
write_data len 360, time 1000000, type sync atom moof
write_data len 86, time nopts, type trailer atom -
4c7832b81836331c6c37155dc31d95be 2001 delay-moov-empty-track-flush
write_data len 36, time nopts, type header atom ftyp
write_data len 1123, time nopts, type header atom -
b7e3c768b9094ebe2fda44979a7f8985 1159 empty-moov-header
write_data len 796, time 0, type sync atom moof
write_data len 788, time 1000000, type sync atom moof
a0165f4a26a409212b0946e981bdefb9 1584 empty-moov-content
write_data len 148, time nopts, type trailer atom -
write_data len 1159, time nopts, type header atom ftyp
b7e3c768b9094ebe2fda44979a7f8985 1159 delay-moov-header
write_data len 796, time 0, type sync atom moof
write_data len 788, time 1000000, type sync atom moof
a0165f4a26a409212b0946e981bdefb9 1584 delay-moov-content
write_data len 148, time nopts, type trailer atom -
write_data len 24, time nopts, type header atom -
write_data len 1123, time nopts, type header atom -
write_data len 884, time 0, type sync atom sidx
write_data len 876, time 1000000, type sync atom sidx
272a474cfd2a68cc5f05b426b14a2b7d 876 empty-moov-second-frag
write_data len 148, time nopts, type trailer atom -
write_data len 24, time nopts, type header atom -
write_data len 1123, time nopts, type header atom -
write_data len 876, time 1000000, type sync atom sidx
272a474cfd2a68cc5f05b426b14a2b7d 876 empty-moov-second-frag-discont
write_data len 110, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom -
write_data len 876, time 1000000, type sync atom sidx
272a474cfd2a68cc5f05b426b14a2b7d 876 delay-moov-second-frag-discont
write_data len 110, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom ftyp
6ec3698bcc86013e0016e3d47d230363 1219 delay-moov-elst-init
write_data len 988, time -33333, type sync atom sidx
write_data len 996, time 966667, type sync atom sidx
fcae8f40e015b59aabc8d4a99a759ca1 996 delay-moov-elst-second-frag
write_data len 148, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom ftyp
6ec3698bcc86013e0016e3d47d230363 1219 delay-moov-elst-init-discont
write_data len 996, time 966667, type sync atom sidx
fcae8f40e015b59aabc8d4a99a759ca1 996 delay-moov-elst-second-frag-discont
write_data len 110, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom ftyp
c3681590a292cb9ca19a5a982e530166 1219 delay-moov-elst-signal-init
write_data len 1004, time -33333, type sync atom sidx
write_data len 996, time 966667, type sync atom sidx
aa5462cc0d2144f72154d9c309edb57d 996 delay-moov-elst-signal-second-frag
write_data len 148, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom ftyp
c3681590a292cb9ca19a5a982e530166 1219 delay-moov-elst-signal-init-discont
write_data len 996, time 966667, type sync atom sidx
aa5462cc0d2144f72154d9c309edb57d 996 delay-moov-elst-signal-second-frag-discont
write_data len 110, time nopts, type trailer atom -
write_data len 1219, time nopts, type header atom ftyp
write_data len 2572, time -333333, type sync atom sidx
write_data len 996, time 5166667, type sync atom sidx
write_data len 148, time nopts, type trailer atom -
f12d4a0e054abcc508cc0d28cb320e57 4935 vfr
write_data len 1219, time nopts, type header atom ftyp
write_data len 2572, time -333333, type sync atom sidx
write_data len 996, time 5166667, type sync atom sidx
write_data len 148, time nopts, type trailer atom -
f12d4a0e054abcc508cc0d28cb320e57 4935 vfr-noduration
write_data len 1231, time nopts, type header atom ftyp
write_data len 1500, time -333333, type sync atom moof
write_data len 1500, time nopts, type unknown atom -
write_data len 916, time nopts, type unknown atom -
write_data len 1500, time 9666667, type sync atom moof
write_data len 1500, time nopts, type unknown atom -
write_data len 1004, time nopts, type unknown atom -
write_data len 148, time nopts, type trailer atom -
3c2c3f98c8a047f0ecefff07570fd457 9299 large_frag