On Sat, Nov 15, 2014 at 02:50:38AM +0100, Carl Eugen Hoyos wrote: > Hi! > > Attached patch fixes ticket #4107 for me. > An alternative would be to force the sar to 4:3 > if h264 10bit 1440x1080 video has sar 3:4. > > Please review, Carl Eugen
> mxfdec.c | 4 ++++ > utils.c | 15 +++++++++++++++ > 2 files changed, 19 insertions(+) > e669a2a2f5050b9fc4165c818b97e6d11ead87a5 patchmxfdar.diff > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > index b533e2a..3ac5e68 100644 > --- a/libavformat/mxfdec.c > +++ b/libavformat/mxfdec.c > @@ -1771,6 +1771,10 @@ static int mxf_parse_structural_metadata(MXFContext > *mxf) > if (source_track->sequence->origin) { > av_dict_set_int(&st->metadata, "source_track_origin", > source_track->sequence->origin, 0); > } > + if (descriptor->aspect_ratio.num && > descriptor->aspect_ratio.den) { > + av_dict_set_int(&st->metadata, "display_aspect_ratio_num", > descriptor->aspect_ratio.num, 0); > + av_dict_set_int(&st->metadata, "display_aspect_ratio_den", > descriptor->aspect_ratio.den, 0); > + } > } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { > container_ul = mxf_get_codec_ul(mxf_sound_essence_container_uls, > essence_container_ul); > /* Only overwrite existing codec ID if it is unset or A-law, > which is the default according to SMPTE RP 224. */ > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 8da8db4..d90541c 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -3298,6 +3298,8 @@ int avformat_find_stream_info(AVFormatContext *ic, > AVDictionary **options) > for (i = 0; i < ic->nb_streams; i++) { > st = ic->streams[i]; > if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { > + AVDictionaryEntry *dar; > + int darnum = 0, darden = 0; > if (st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && > !st->codec->codec_tag && !st->codec->bits_per_coded_sample) { > uint32_t tag= > avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); > if (avpriv_find_pix_fmt(avpriv_get_raw_pix_fmt_tags(), tag) > == st->codec->pix_fmt) > @@ -3346,6 +3348,19 @@ int avformat_find_stream_info(AVFormatContext *ic, > AVDictionary **options) > st->r_frame_rate.den = st->time_base.num; > } > } > + dar = av_dict_get(st->metadata, "display_aspect_ratio_num", > NULL, 0); > + if (dar) > + darnum = strtol(dar->value, NULL, 0); > + dar = av_dict_get(st->metadata, "display_aspect_ratio_den", > NULL, 0); > + if (dar) > + darden = strtol(dar->value, NULL, 0); > + if (darnum && darden) { > + av_reduce(&st->sample_aspect_ratio.num, > &st->sample_aspect_ratio.den, > + st->codec->height * darnum, st->codec->width * > darden, > + INT32_MAX); > + av_dict_set(&st->metadata, "display_aspect_ratio_num", NULL, > 0); > + av_dict_set(&st->metadata, "display_aspect_ratio_den", NULL, > 0); > + } I suggest you add a documented as private/internal display_aspect_ratio to AVStream instead of metadata also av_reduce can be replaced by av_mul_q which is probably simpler [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB DNS cache poisoning attacks, popular search engine, Google internet authority dont be evil, please
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel