diff mbox

[FFmpeg-devel,1/3] lavc/utils.c: Subtract skip_samples when frame is DISCARDed.

Message ID 1474915372-25376-1-git-send-email-isasi@google.com
State Superseded
Headers show

Commit Message

Sasi Inguva Sept. 26, 2016, 6:42 p.m. UTC
Signed-off-by: Sasi Inguva <isasi@google.com>
---
 libavcodec/utils.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

Comments

Michael Niedermayer Sept. 27, 2016, 1:01 a.m. UTC | #1
On Mon, Sep 26, 2016 at 11:42:50AM -0700, Sasi Inguva wrote:
> Signed-off-by: Sasi Inguva <isasi@google.com>
> ---
>  libavcodec/utils.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)

applying just this patch breaks

./ffmpeg_g -f u8 -ar 16000 -ac 1 -i sync_audio.raw -acodec libmp3lame test.mov
./ffmpeg_g -i test.mov test.mov.wav

applying both doesnt break this though
not sure if thats a problem or not ...

version bump is missing


[...]
Sasi Inguva Sept. 27, 2016, 1:42 a.m. UTC | #2
On Mon, Sep 26, 2016 at 6:01 PM, Michael Niedermayer <michael@niedermayer.cc
> wrote:

> On Mon, Sep 26, 2016 at 11:42:50AM -0700, Sasi Inguva wrote:
> > Signed-off-by: Sasi Inguva <isasi@google.com>
> > ---
> >  libavcodec/utils.c | 16 +++++++---------
> >  1 file changed, 7 insertions(+), 9 deletions(-)
>
> applying just this patch breaks
>
> ./ffmpeg_g -f u8 -ar 16000 -ac 1 -i sync_audio.raw -acodec libmp3lame
> test.mov
> ./ffmpeg_g -i test.mov test.mov.wav
>
> applying both doesnt break this though
> not sure if thats a problem or not ...
>
> Yes. it needs the next patch setting skip_samples correctly in mov.c for
this file to work.


> version bump is missing
>
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Dictatorship naturally arises out of democracy, and the most aggravated
> form of tyranny and slavery out of the most extreme liberty. -- Plato
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Sasi Inguva Sept. 27, 2016, 1:42 a.m. UTC | #3
On Mon, Sep 26, 2016 at 6:01 PM, Michael Niedermayer <michael@niedermayer.cc
> wrote:

> On Mon, Sep 26, 2016 at 11:42:50AM -0700, Sasi Inguva wrote:
> > Signed-off-by: Sasi Inguva <isasi@google.com>
> > ---
> >  libavcodec/utils.c | 16 +++++++---------
> >  1 file changed, 7 insertions(+), 9 deletions(-)
>
> applying just this patch breaks
>
> ./ffmpeg_g -f u8 -ar 16000 -ac 1 -i sync_audio.raw -acodec libmp3lame
> test.mov
> ./ffmpeg_g -i test.mov test.mov.wav
>
> applying both doesnt break this though
> not sure if thats a problem or not ...
>
> version bump is missing
>
> Done.

>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Dictatorship naturally arises out of democracy, and the most aggravated
> form of tyranny and slavery out of the most extreme liberty. -- Plato
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
diff mbox

Patch

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index b0345b6..6323156 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2320,7 +2320,6 @@  int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
         uint32_t discard_padding = 0;
         uint8_t skip_reason = 0;
         uint8_t discard_reason = 0;
-        int demuxer_skip_samples = 0;
         // copy to ensure we do not change avpkt
         AVPacket tmp = *avpkt;
         int did_split = av_packet_split_side_data(&tmp);
@@ -2328,7 +2327,6 @@  int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
         if (ret < 0)
             goto fail;
 
-        demuxer_skip_samples = avctx->internal->skip_samples;
         avctx->internal->pkt = &tmp;
         if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
             ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, &tmp);
@@ -2353,13 +2351,6 @@  int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
                 frame->sample_rate = avctx->sample_rate;
         }
 
-
-        if (frame->flags & AV_FRAME_FLAG_DISCARD) {
-            // If using discard frame flag, ignore skip_samples set by the decoder.
-            avctx->internal->skip_samples = demuxer_skip_samples;
-            *got_frame_ptr = 0;
-        }
-
         side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
         if(side && side_size>=10) {
             avctx->internal->skip_samples = AV_RL32(side);
@@ -2369,6 +2360,13 @@  int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
             skip_reason = AV_RL8(side + 8);
             discard_reason = AV_RL8(side + 9);
         }
+
+        if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr &&
+            !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
+            avctx->internal->skip_samples -= frame->nb_samples;
+            *got_frame_ptr = 0;
+        }
+
         if (avctx->internal->skip_samples > 0 && *got_frame_ptr &&
             !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) {
             if(frame->nb_samples <= avctx->internal->skip_samples){