Commit dd6c8575 authored by Andreas Cadhalpun's avatar Andreas Cadhalpun

examples/demuxing_decoding: use properties from frame instead of video_dec_ctx

This is more robust.

And only check if there is actually a frame returned.
Reviewed-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
parent fdc64a10
...@@ -81,8 +81,11 @@ static int decode_packet(int *got_frame, int cached) ...@@ -81,8 +81,11 @@ static int decode_packet(int *got_frame, int cached)
fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret)); fprintf(stderr, "Error decoding video frame (%s)\n", av_err2str(ret));
return ret; return ret;
} }
if (video_dec_ctx->width != width || video_dec_ctx->height != height ||
video_dec_ctx->pix_fmt != pix_fmt) { if (*got_frame) {
if (frame->width != width || frame->height != height ||
frame->format != pix_fmt) {
/* To handle this change, one could call av_image_alloc again and /* To handle this change, one could call av_image_alloc again and
* decode the following frames into another rawvideo file. */ * decode the following frames into another rawvideo file. */
fprintf(stderr, "Error: Width, height and pixel format have to be " fprintf(stderr, "Error: Width, height and pixel format have to be "
...@@ -91,12 +94,11 @@ static int decode_packet(int *got_frame, int cached) ...@@ -91,12 +94,11 @@ static int decode_packet(int *got_frame, int cached)
"old: width = %d, height = %d, format = %s\n" "old: width = %d, height = %d, format = %s\n"
"new: width = %d, height = %d, format = %s\n", "new: width = %d, height = %d, format = %s\n",
width, height, av_get_pix_fmt_name(pix_fmt), width, height, av_get_pix_fmt_name(pix_fmt),
video_dec_ctx->width, video_dec_ctx->height, frame->width, frame->height,
av_get_pix_fmt_name(video_dec_ctx->pix_fmt)); av_get_pix_fmt_name(frame->format));
return -1; return -1;
} }
if (*got_frame) {
printf("video_frame%s n:%d coded_n:%d pts:%s\n", printf("video_frame%s n:%d coded_n:%d pts:%s\n",
cached ? "(cached)" : "", cached ? "(cached)" : "",
video_frame_count++, frame->coded_picture_number, video_frame_count++, frame->coded_picture_number,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment