[vlc-devel] [PATCH] avcodec/avformat: simplify AVRational copying

Steve Lhomme robux4 at videolabs.io
Mon Apr 10 08:28:57 CEST 2017


---
 modules/codec/avcodec/encoder.c | 5 +----
 modules/demux/avformat/mux.c    | 3 +--
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/modules/codec/avcodec/encoder.c b/modules/codec/avcodec/encoder.c
index 29627011bd..028907079e 100644
--- a/modules/codec/avcodec/encoder.c
+++ b/modules/codec/avcodec/encoder.c
@@ -252,10 +252,7 @@ static void probe_video_frame_rate( encoder_t *p_enc, AVCodecContext *p_context,
     if( p_codec->supported_framerates )
     {
         /* We are finding fps values so 1/time_base */
-        AVRational target = {
-            .num = p_context->time_base.den,
-            .den = p_context->time_base.num
-        };
+        AVRational target = p_context->time_base;
         int idx = av_find_nearest_q_idx(target, p_codec->supported_framerates);
 
         p_context->time_base.num = p_codec->supported_framerates[idx].den ?
diff --git a/modules/demux/avformat/mux.c b/modules/demux/avformat/mux.c
index 9072c2f8e1..20c5e2495b 100644
--- a/modules/demux/avformat/mux.c
+++ b/modules/demux/avformat/mux.c
@@ -272,8 +272,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
                    fmt->video.i_sar_den, 1 << 30 /* something big */ );
         msg_Dbg(p_mux, "Muxing aspect ratio will be %d/%d",
                 fmt->video.i_sar_num, fmt->video.i_sar_den);
-        stream->sample_aspect_ratio.den = codec->sample_aspect_ratio.den;
-        stream->sample_aspect_ratio.num = codec->sample_aspect_ratio.num;
+        stream->sample_aspect_ratio = codec->sample_aspect_ratio;
         stream->time_base.den = fmt->video.i_frame_rate;
         stream->time_base.num = fmt->video.i_frame_rate_base;
         if (fmt->i_bitrate == 0) {
-- 
2.11.1



More information about the vlc-devel mailing list