[FFmpeg-devel] [PATCH] libavformat: Add H264 API test

Michael Niedermayer michaelni at gmx.at
Mon Jun 22 14:27:00 CEST 2015


On Mon, Jun 22, 2015 at 12:50:22PM +0300, Ludmila Glinskih wrote:
> Result differs in pkt_duration and time_base.den for some reason.
> Right now it tests only one example (adjusted to match the output).
> 
[...]

> +    pkt.data = NULL;
> +    pkt.size = 0;
> +    if (pkt.pts == AV_NOPTS_VALUE)
> +        pkt.pts = pkt.dts = i;

> +    int flag = 0;

should be moved to the top of the function, some compilers dont
like mixed declarations and code.


> +    while (!flag) {
> +        if (pkt.stream_index != video_stream)
> +            break;
> +        get_frame = 0;
> +        if (avcodec_decode_video2(ctx, fr, &get_frame, &pkt) < 0 || get_frame == 0)
> +            flag = 1;
> +        if (get_frame) {
> +            number_of_written_bytes = av_image_copy_to_buffer(byte_buffer, byte_buffer_size,
> +                                    (const uint8_t* const *)fr->data, (const int*) fr->linesize,
> +                                    ctx->pix_fmt, ctx->width, ctx->height, 1);
> +            printf("%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08"PRIx32"\n", video_stream,
> +                    fr->pkt_pts, fr->pkt_dts, fr->pkt_duration,
> +                    number_of_written_bytes, av_adler32_update(0, (const uint8_t*)byte_buffer, number_of_written_bytes));
> +        }
> +        i++;
> +    }
> +    av_free_packet(&pkt);
> +    av_frame_free(&fr);
> +    avcodec_close(ctx);
> +    avformat_close_input(&fmt_ctx);
> +    avcodec_free_context(&ctx);
> +    av_freep(&byte_buffer);
> +    return 0;
> +}
> +
> +int main(int argc, char **argv)
> +{
> +    av_register_all();

> +    video_decode_example(argv[1]);

missing check on argc before use of the first argument

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150622/7d87f2c3/attachment.asc>


More information about the ffmpeg-devel mailing list