diff mbox

[FFmpeg-devel,1/2] lavc: add trailing_padding to AVCodecContext to match AVCodecParameters.

Message ID 1471291987-2220-2-git-send-email-jtoohill@google.com
State Accepted
Commit c3c4c72665b9fbb06d8e84e6350c1148b3c55498
Headers show

Commit Message

Jon Toohill Aug. 15, 2016, 8:13 p.m. UTC
Shows encoder delay/padding in the stream summary if they are set.
---
 doc/APIchanges       |  4 ++++
 libavcodec/avcodec.h | 11 +++++++++++
 libavcodec/utils.c   | 40 +++++++++++++++++++++++-----------------
 libavcodec/version.h |  2 +-
 4 files changed, 39 insertions(+), 18 deletions(-)

Comments

Michael Niedermayer Aug. 16, 2016, 10:28 a.m. UTC | #1
On Mon, Aug 15, 2016 at 01:13:06PM -0700, Jon Toohill wrote:
> Shows encoder delay/padding in the stream summary if they are set.
> ---
>  doc/APIchanges       |  4 ++++
>  libavcodec/avcodec.h | 11 +++++++++++
>  libavcodec/utils.c   | 40 +++++++++++++++++++++++-----------------
>  libavcodec/version.h |  2 +-
>  4 files changed, 39 insertions(+), 18 deletions(-)

applied

thanks

[...]
Paul B Mahol Aug. 16, 2016, 10:55 a.m. UTC | #2
On 8/16/16, Michael Niedermayer <michael@niedermayer.cc> wrote:
> On Mon, Aug 15, 2016 at 01:13:06PM -0700, Jon Toohill wrote:
>> Shows encoder delay/padding in the stream summary if they are set.
>> ---
>>  doc/APIchanges       |  4 ++++
>>  libavcodec/avcodec.h | 11 +++++++++++
>>  libavcodec/utils.c   | 40 +++++++++++++++++++++++-----------------
>>  libavcodec/version.h |  2 +-
>>  4 files changed, 39 insertions(+), 18 deletions(-)
>
> applied
>

Please revert, no proper review was made.

thanks
Michael Niedermayer Aug. 16, 2016, 11:11 a.m. UTC | #3
On Tue, Aug 16, 2016 at 12:55:17PM +0200, Paul B Mahol wrote:
> On 8/16/16, Michael Niedermayer <michael@niedermayer.cc> wrote:
> > On Mon, Aug 15, 2016 at 01:13:06PM -0700, Jon Toohill wrote:
> >> Shows encoder delay/padding in the stream summary if they are set.
> >> ---
> >>  doc/APIchanges       |  4 ++++
> >>  libavcodec/avcodec.h | 11 +++++++++++
> >>  libavcodec/utils.c   | 40 +++++++++++++++++++++++-----------------
> >>  libavcodec/version.h |  2 +-
> >>  4 files changed, 39 insertions(+), 18 deletions(-)
> >
> > applied
> >
> 
> Please revert, no proper review was made.

please elaborate, what is the problem with the patch ?

also this patch was posted 4 times already
in may, june and july, noone objected to it previously. in fact the
only reply i see is a review from me in may

The only substantial difference to the previous patch i see was the
subject "lavc: show gapless info in stream summary"

[...]
diff mbox

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index 209ab41..74145b2 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@  libavutil:     2015-08-28
 
 API changes, most recent first:
 
+2016-08-15 - xxxxxxx - lavc 57.53.100 - avcodec.h
+  Add trailing_padding to AVCodecContext to match the corresponding
+  field in AVCodecParameters.
+
 2016-08-04 - xxxxxxx - lavf 57.46.100 - avformat.h
   Add av_get_frame_filename2()
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 06c2b89..b43ee5a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3524,6 +3524,17 @@  typedef struct AVCodecContext {
 #define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1
 #endif
 
+    /**
+     * Audio only. The amount of padding (in samples) appended by the encoder to
+     * the end of the audio. I.e. this number of decoded samples must be
+     * discarded by the caller from the end of the stream to get the original
+     * audio without any trailing padding.
+     *
+     * - decoding: unused
+     * - encoding: unused
+     */
+    int trailing_padding;
+
 } AVCodecContext;
 
 AVRational av_codec_get_pkt_timebase         (const AVCodecContext *avctx);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 783f62c..6f4d553 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3258,6 +3258,10 @@  void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
             && enc->bits_per_raw_sample != av_get_bytes_per_sample(enc->sample_fmt) * 8)
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      " (%d bit)", enc->bits_per_raw_sample);
+        if (enc->initial_padding || enc->trailing_padding) {
+            snprintf(buf + strlen(buf), buf_size - strlen(buf),
+                     ", delay %d, padding %d", enc->initial_padding, enc->trailing_padding);
+        }
         break;
     case AVMEDIA_TYPE_DATA:
         if (av_log_get_level() >= AV_LOG_DEBUG) {
@@ -4103,14 +4107,15 @@  int avcodec_parameters_from_context(AVCodecParameters *par,
         par->video_delay         = codec->has_b_frames;
         break;
     case AVMEDIA_TYPE_AUDIO:
-        par->format          = codec->sample_fmt;
-        par->channel_layout  = codec->channel_layout;
-        par->channels        = codec->channels;
-        par->sample_rate     = codec->sample_rate;
-        par->block_align     = codec->block_align;
-        par->frame_size      = codec->frame_size;
-        par->initial_padding = codec->initial_padding;
-        par->seek_preroll    = codec->seek_preroll;
+        par->format           = codec->sample_fmt;
+        par->channel_layout   = codec->channel_layout;
+        par->channels         = codec->channels;
+        par->sample_rate      = codec->sample_rate;
+        par->block_align      = codec->block_align;
+        par->frame_size       = codec->frame_size;
+        par->initial_padding  = codec->initial_padding;
+        par->trailing_padding = codec->trailing_padding;
+        par->seek_preroll     = codec->seek_preroll;
         break;
     case AVMEDIA_TYPE_SUBTITLE:
         par->width  = codec->width;
@@ -4157,15 +4162,16 @@  int avcodec_parameters_to_context(AVCodecContext *codec,
         codec->has_b_frames           = par->video_delay;
         break;
     case AVMEDIA_TYPE_AUDIO:
-        codec->sample_fmt      = par->format;
-        codec->channel_layout  = par->channel_layout;
-        codec->channels        = par->channels;
-        codec->sample_rate     = par->sample_rate;
-        codec->block_align     = par->block_align;
-        codec->frame_size      = par->frame_size;
-        codec->delay           =
-        codec->initial_padding = par->initial_padding;
-        codec->seek_preroll    = par->seek_preroll;
+        codec->sample_fmt       = par->format;
+        codec->channel_layout   = par->channel_layout;
+        codec->channels         = par->channels;
+        codec->sample_rate      = par->sample_rate;
+        codec->block_align      = par->block_align;
+        codec->frame_size       = par->frame_size;
+        codec->delay            =
+        codec->initial_padding  = par->initial_padding;
+        codec->trailing_padding = par->trailing_padding;
+        codec->seek_preroll     = par->seek_preroll;
         break;
     case AVMEDIA_TYPE_SUBTITLE:
         codec->width  = par->width;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index a697261..cdfc4f9 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,7 +28,7 @@ 
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  57
-#define LIBAVCODEC_VERSION_MINOR  52
+#define LIBAVCODEC_VERSION_MINOR  53
 #define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \