[FFmpeg-devel,2/2] avformat/mxfenc: calculate and store DAR from user SAR

Submitted by Paul B Mahol on Dec. 9, 2018, 1:38 p.m.

Details

Message ID 20181209133855.28636-2-onemda@gmail.com
State New
Headers show

Commit Message

Paul B Mahol Dec. 9, 2018, 1:38 p.m.
Fixes #5155

Signed-off-by: Paul B Mahol <onemda@gmail.com>
---
 libavformat/mxfenc.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Michael Niedermayer Dec. 9, 2018, 10:04 p.m.
On Sun, Dec 09, 2018 at 02:38:55PM +0100, Paul B Mahol wrote:
> Fixes #5155
> 
> Signed-off-by: Paul B Mahol <onemda@gmail.com>
> ---
>  libavformat/mxfenc.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 3549b4137d..b3c8dc43bd 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -2726,6 +2726,12 @@ static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
>          }
>      }
>  
> +    if (st->codecpar->sample_aspect_ratio.num && st->codecpar->sample_aspect_ratio.den) {
> +        av_reduce_q(&sc->aspect_ratio,
> +                    av_mul_q(st->codecpar->sample_aspect_ratio,
> +                             av_make_q(st->codecpar->width, st->codecpar->height)), INT_MAX);
> +    }

AVRational uses int, so av_reduce* should not be needed if INT_MAX is ok

[...]

Patch hide | download patch | download mbox

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 3549b4137d..b3c8dc43bd 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2726,6 +2726,12 @@  static int mxf_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
     }
 
+    if (st->codecpar->sample_aspect_ratio.num && st->codecpar->sample_aspect_ratio.den) {
+        av_reduce_q(&sc->aspect_ratio,
+                    av_mul_q(st->codecpar->sample_aspect_ratio,
+                             av_make_q(st->codecpar->width, st->codecpar->height)), INT_MAX);
+    }
+
     if (st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO) {
         if (!mxf_parse_mpeg2_frame(s, st, pkt, &ie)) {
             av_log(s, AV_LOG_ERROR, "could not get mpeg2 profile and level\n");