Commit 8a4a5f6f authored by Stefano Sabatini's avatar Stefano Sabatini Committed by Anton Khirnov

lavc: add format field to AVFrame

The format is a per-frame property, having it in AVFrame simplify the
operation of extraction of that information, since avoids the need to
access the codec/stream context.
parent 3a2ddf7c
...@@ -1272,6 +1272,15 @@ typedef struct AVFrame { ...@@ -1272,6 +1272,15 @@ typedef struct AVFrame {
* - decoding: Read by user. * - decoding: Read by user.
*/ */
int width, height; int width, height;
/**
* format of the frame, -1 if unknown or unset
* Values correspond to enum PixelFormat for video frames,
* enum AVSampleFormat for audio)
* - encoding: unused
* - decoding: Read by user.
*/
int format;
} AVFrame; } AVFrame;
struct AVCodecInternal; struct AVCodecInternal;
......
...@@ -602,6 +602,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx, ...@@ -602,6 +602,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx,
picture->sample_aspect_ratio = avctx->sample_aspect_ratio; picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
picture->width = avctx->width; picture->width = avctx->width;
picture->height = avctx->height; picture->height = avctx->height;
picture->format = avctx->pix_fmt;
/* /*
* A later call with avkpt->size == 0 may loop over all threads, * A later call with avkpt->size == 0 may loop over all threads,
......
...@@ -585,6 +585,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){ ...@@ -585,6 +585,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){
pic->pts= AV_NOPTS_VALUE; pic->pts= AV_NOPTS_VALUE;
pic->key_frame= 1; pic->key_frame= 1;
pic->sample_aspect_ratio = (AVRational){0, 1}; pic->sample_aspect_ratio = (AVRational){0, 1};
pic->format = -1; /* unknown */
} }
AVFrame *avcodec_alloc_frame(void){ AVFrame *avcodec_alloc_frame(void){
...@@ -862,6 +863,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi ...@@ -862,6 +863,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
picture->sample_aspect_ratio = avctx->sample_aspect_ratio; picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
picture->width = avctx->width; picture->width = avctx->width;
picture->height = avctx->height; picture->height = avctx->height;
picture->format = avctx->pix_fmt;
} }
emms_c(); //needed to avoid an emms_c() call before every return; emms_c(); //needed to avoid an emms_c() call before every return;
...@@ -983,6 +985,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, ...@@ -983,6 +985,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
if (ret >= 0 && *got_frame_ptr) { if (ret >= 0 && *got_frame_ptr) {
avctx->frame_number++; avctx->frame_number++;
frame->pkt_dts = avpkt->dts; frame->pkt_dts = avpkt->dts;
if (frame->format == AV_SAMPLE_FMT_NONE)
frame->format = avctx->sample_fmt;
} }
} }
return ret; return ret;
......
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