diff mbox

[FFmpeg-devel,v2] avcodec/decode: do not treat discarded frames as eof when draining

Message ID 20170501003635.17241-1-mfcc64@gmail.com
State Accepted
Commit 9b4648a2cdeb31bf15eb8e238d34b51fe7ff0b87
Headers show

Commit Message

Muhammad Faiz May 1, 2017, 12:36 a.m. UTC
Fix fate failures:
    make fate-mov THREADS=32

Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
---
 libavcodec/decode.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

wm4 May 1, 2017, 2:01 p.m. UTC | #1
On Mon,  1 May 2017 07:36:35 +0700
Muhammad Faiz <mfcc64@gmail.com> wrote:

> Fix fate failures:
>     make fate-mov THREADS=32
> 
> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
> ---
>  libavcodec/decode.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> index edfae55..e330f14 100644
> --- a/libavcodec/decode.c
> +++ b/libavcodec/decode.c
> @@ -369,7 +369,7 @@ static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
>      AVPacket           *pkt = ds->in_pkt;
>      // copy to ensure we do not change pkt
>      AVPacket tmp;
> -    int got_frame, did_split;
> +    int got_frame, actual_got_frame, did_split;
>      int ret;
>  
>      if (!pkt->data && !avci->draining) {
> @@ -431,6 +431,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>          }
>      }
>      emms_c();
> +    actual_got_frame = got_frame;
>  
>      if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
>          if (frame->flags & AV_FRAME_FLAG_DISCARD)
> @@ -568,8 +569,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>          avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
>  #endif
>  
> -    /* do not stop draining when got_frame != 0 or ret < 0 */
> -    if (avctx->internal->draining && !got_frame) {
> +    /* do not stop draining when actual_got_frame != 0 or ret < 0 */
> +    /* got_frame == 0 but actual_got_frame != 0 when frame is discarded */
> +    if (avctx->internal->draining && !actual_got_frame) {
>          if (ret < 0) {
>              /* prevent infinite loop if a decoder wrongly always return error on draining */
>              /* reasonable nb_errors_max = maximum b frames + thread count */

I think that's reasonable.
Muhammad Faiz May 2, 2017, 6:43 p.m. UTC | #2
On Mon, May 1, 2017 at 9:01 PM, wm4 <nfxjfg@googlemail.com> wrote:
> On Mon,  1 May 2017 07:36:35 +0700
> Muhammad Faiz <mfcc64@gmail.com> wrote:
>
>> Fix fate failures:
>>     make fate-mov THREADS=32
>>
>> Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
>> ---
>>  libavcodec/decode.c | 8 +++++---
>>  1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/libavcodec/decode.c b/libavcodec/decode.c
>> index edfae55..e330f14 100644
>> --- a/libavcodec/decode.c
>> +++ b/libavcodec/decode.c
>> @@ -369,7 +369,7 @@ static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
>>      AVPacket           *pkt = ds->in_pkt;
>>      // copy to ensure we do not change pkt
>>      AVPacket tmp;
>> -    int got_frame, did_split;
>> +    int got_frame, actual_got_frame, did_split;
>>      int ret;
>>
>>      if (!pkt->data && !avci->draining) {
>> @@ -431,6 +431,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>          }
>>      }
>>      emms_c();
>> +    actual_got_frame = got_frame;
>>
>>      if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
>>          if (frame->flags & AV_FRAME_FLAG_DISCARD)
>> @@ -568,8 +569,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>>          avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
>>  #endif
>>
>> -    /* do not stop draining when got_frame != 0 or ret < 0 */
>> -    if (avctx->internal->draining && !got_frame) {
>> +    /* do not stop draining when actual_got_frame != 0 or ret < 0 */
>> +    /* got_frame == 0 but actual_got_frame != 0 when frame is discarded */
>> +    if (avctx->internal->draining && !actual_got_frame) {
>>          if (ret < 0) {
>>              /* prevent infinite loop if a decoder wrongly always return error on draining */
>>              /* reasonable nb_errors_max = maximum b frames + thread count */
>
> I think that's reasonable.

Applied.

Thank's.
diff mbox

Patch

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index edfae55..e330f14 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -369,7 +369,7 @@  static int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame)
     AVPacket           *pkt = ds->in_pkt;
     // copy to ensure we do not change pkt
     AVPacket tmp;
-    int got_frame, did_split;
+    int got_frame, actual_got_frame, did_split;
     int ret;
 
     if (!pkt->data && !avci->draining) {
@@ -431,6 +431,7 @@  FF_ENABLE_DEPRECATION_WARNINGS
         }
     }
     emms_c();
+    actual_got_frame = got_frame;
 
     if (avctx->codec->type == AVMEDIA_TYPE_VIDEO) {
         if (frame->flags & AV_FRAME_FLAG_DISCARD)
@@ -568,8 +569,9 @@  FF_ENABLE_DEPRECATION_WARNINGS
         avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
 #endif
 
-    /* do not stop draining when got_frame != 0 or ret < 0 */
-    if (avctx->internal->draining && !got_frame) {
+    /* do not stop draining when actual_got_frame != 0 or ret < 0 */
+    /* got_frame == 0 but actual_got_frame != 0 when frame is discarded */
+    if (avctx->internal->draining && !actual_got_frame) {
         if (ret < 0) {
             /* prevent infinite loop if a decoder wrongly always return error on draining */
             /* reasonable nb_errors_max = maximum b frames + thread count */