@@ -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;