[FFmpeg-devel] [PATCH] lavc/samidec: don't error on empty packets
Rodger Combs
rodger.combs at gmail.com
Sat Dec 1 05:10:06 EET 2018
No change to output; just prevents error spam
---
libavcodec/samidec.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/libavcodec/samidec.c b/libavcodec/samidec.c
index e32f238c62..7ea67b5597 100644
--- a/libavcodec/samidec.c
+++ b/libavcodec/samidec.c
@@ -38,6 +38,7 @@ typedef struct {
int readorder;
} SAMIContext;
+// Returns 1 if valid content was decoded; 0 if none; <0 if error
static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
{
SAMIContext *sami = avctx->priv_data;
@@ -84,7 +85,7 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
while (av_isspace(*p))
p++;
if (!strncmp(p, " ", 6)) {
- ret = -1;
+ ret = 0;
goto end;
}
@@ -126,6 +127,8 @@ static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
goto end;
av_bprintf(&sami->full, "%s", sami->encoded_content.str);
+ ret = 1;
+
end:
av_free(dupsrc);
return ret;
@@ -142,10 +145,12 @@ static int sami_decode_frame(AVCodecContext *avctx,
int ret = sami_paragraph_to_ass(avctx, ptr);
if (ret < 0)
return ret;
- // TODO: pass escaped sami->encoded_source.str as source
- ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, NULL);
- if (ret < 0)
- return ret;
+ if (ret > 0) {
+ // TODO: pass escaped sami->encoded_source.str as source
+ ret = ff_ass_add_rect(sub, sami->full.str, sami->readorder++, 0, NULL, NULL);
+ if (ret < 0)
+ return ret;
+ }
}
*got_sub_ptr = sub->num_rects > 0;
return avpkt->size;
--
2.19.1
More information about the ffmpeg-devel
mailing list