The sample aspect ratio is a per-frame property, so it makes sense to
define it in AVFrame rather than in the codec/stream context.
Simplify application-level sample aspect ratio information extraction,
and allow further simplifications.
| ... | ... |
@@ -1651,7 +1651,7 @@ static int input_request_frame(AVFilterLink *link) |
| 1651 | 1651 |
|
| 1652 | 1652 |
picref->pts = pts; |
| 1653 | 1653 |
picref->pos = pkt.pos; |
| 1654 |
- picref->video->pixel_aspect = priv->is->video_st->codec->sample_aspect_ratio; |
|
| 1654 |
+ picref->video->pixel_aspect = priv->frame->sample_aspect_ratio; |
|
| 1655 | 1655 |
avfilter_start_frame(link, picref); |
| 1656 | 1656 |
avfilter_draw_slice(link, 0, link->h, 1); |
| 1657 | 1657 |
avfilter_end_frame(link); |
| ... | ... |
@@ -1047,6 +1047,7 @@ int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame, |
| 1047 | 1047 |
frame->top_field_first = picref->video->top_field_first; |
| 1048 | 1048 |
frame->key_frame = picref->video->key_frame; |
| 1049 | 1049 |
frame->pict_type = picref->video->pict_type; |
| 1050 |
+ frame->sample_aspect_ratio = picref->video->pixel_aspect; |
|
| 1050 | 1051 |
|
| 1051 | 1052 |
return 1; |
| 1052 | 1053 |
} |
| ... | ... |
@@ -1258,6 +1258,13 @@ typedef struct AVFrame {
|
| 1258 | 1258 |
* decoding: set by AVCodecContext.get_buffer() |
| 1259 | 1259 |
*/ |
| 1260 | 1260 |
uint8_t **extended_data; |
| 1261 |
+ |
|
| 1262 |
+ /** |
|
| 1263 |
+ * sample aspect ratio for the video frame, 0/1 if unknown\unspecified |
|
| 1264 |
+ * - encoding: unused |
|
| 1265 |
+ * - decoding: Read by user. |
|
| 1266 |
+ */ |
|
| 1267 |
+ AVRational sample_aspect_ratio; |
|
| 1261 | 1268 |
} AVFrame; |
| 1262 | 1269 |
|
| 1263 | 1270 |
struct AVCodecInternal; |
| ... | ... |
@@ -599,6 +599,7 @@ int ff_thread_decode_frame(AVCodecContext *avctx, |
| 599 | 599 |
*picture = p->frame; |
| 600 | 600 |
*got_picture_ptr = p->got_frame; |
| 601 | 601 |
picture->pkt_dts = p->avpkt.dts; |
| 602 |
+ picture->sample_aspect_ratio = avctx->sample_aspect_ratio; |
|
| 602 | 603 |
|
| 603 | 604 |
/* |
| 604 | 605 |
* A later call with avkpt->size == 0 may loop over all threads, |
| ... | ... |
@@ -584,6 +584,7 @@ void avcodec_get_frame_defaults(AVFrame *pic){
|
| 584 | 584 |
|
| 585 | 585 |
pic->pts= AV_NOPTS_VALUE; |
| 586 | 586 |
pic->key_frame= 1; |
| 587 |
+ pic->sample_aspect_ratio = (AVRational){0, 1};
|
|
| 587 | 588 |
} |
| 588 | 589 |
|
| 589 | 590 |
AVFrame *avcodec_alloc_frame(void){
|
| ... | ... |
@@ -858,6 +859,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi |
| 858 | 858 |
ret = avctx->codec->decode(avctx, picture, got_picture_ptr, |
| 859 | 859 |
avpkt); |
| 860 | 860 |
picture->pkt_dts= avpkt->dts; |
| 861 |
+ picture->sample_aspect_ratio = avctx->sample_aspect_ratio; |
|
| 861 | 862 |
} |
| 862 | 863 |
|
| 863 | 864 |
emms_c(); //needed to avoid an emms_c() call before every return; |
| ... | ... |
@@ -248,8 +248,8 @@ static int movie_get_frame(AVFilterLink *outlink) |
| 248 | 248 |
movie->frame->pkt_dts : movie->frame->pkt_pts; |
| 249 | 249 |
|
| 250 | 250 |
movie->picref->pos = movie->frame->reordered_opaque; |
| 251 |
- movie->picref->video->pixel_aspect = st->sample_aspect_ratio.num ? |
|
| 252 |
- st->sample_aspect_ratio : movie->codec_ctx->sample_aspect_ratio; |
|
| 251 |
+ if (!movie->frame->sample_aspect_ratio.num) |
|
| 252 |
+ movie->picref->video->pixel_aspect = st->sample_aspect_ratio; |
|
| 253 | 253 |
movie->picref->video->interlaced = movie->frame->interlaced_frame; |
| 254 | 254 |
movie->picref->video->top_field_first = movie->frame->top_field_first; |
| 255 | 255 |
movie->picref->video->key_frame = movie->frame->key_frame; |