Quoting Martin Storsjö (2016-05-17 11:16:55)
> ---
> libavformat/tests/movenc.c | 45 ++++++++++++++++++++-
> tests/ref/fate/movenc | 99
> ++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 143 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c
> index 711e157..c19c6f2 100644
> --- a/libavformat/tests/movenc.c
> +++ b/libavformat/tests/movenc.c
> @@ -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_HEADER: str = "header"; break;
> + case AVIO_DATA_SYNC_POINT: str = "sync"; break;
> + case AVIO_DATA_BOUNDARY_POINT: str = "boundary"; break;
> + case AVIO_DATA_UNKNOWN: str = "unknown"; break;
> + case AVIO_DATA_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_UNKNOWN &&
> + type != AVIO_DATA_TRAILER &&
> + (type != AVIO_DATA_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);
> @@ -666,6 +698,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 opaque.
^^^^^^
Should be unknown I suppose.
--
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel