Message ID | 20200619142650.16870-2-onemda@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [FFmpeg-devel,1/3] avcodec/ccaption_dec: rework non-real-time mode with pop-on captions by delaying | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On Fri, Jun 19, 2020 at 04:26:49PM +0200, Paul B Mahol wrote: > Signed-off-by: Paul B Mahol <onemda@gmail.com> > --- > libavcodec/ccaption_dec.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) this appears to make the output of the following become empty ./ffmpeg -f lavfi -i "movie=tickets/1332/Starship_Troopers.vob[out0+subcc]" -vn -map s -y file.srt file probably here: http://samples.mplayerhq.hu/MPEG-VOB/ClosedCaptions/Starship_Troopers.vob thx [...]
On 6/20/20, Michael Niedermayer <michael@niedermayer.cc> wrote: > On Fri, Jun 19, 2020 at 04:26:49PM +0200, Paul B Mahol wrote: >> Signed-off-by: Paul B Mahol <onemda@gmail.com> >> --- >> libavcodec/ccaption_dec.c | 15 ++++++++++++--- >> 1 file changed, 12 insertions(+), 3 deletions(-) > > this appears to make the output of the following become empty > > ./ffmpeg -f lavfi -i "movie=tickets/1332/Starship_Troopers.vob[out0+subcc]" > -vn -map s -y file.srt > > file probably here: > http://samples.mplayerhq.hu/MPEG-VOB/ClosedCaptions/Starship_Troopers.vob > > thx Fixed locally. > > [...] > -- > 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 >
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c index e67a47508c..fe6933ab5c 100644 --- a/libavcodec/ccaption_dec.c +++ b/libavcodec/ccaption_dec.c @@ -224,6 +224,7 @@ struct Screen { typedef struct CCaptionSubContext { AVClass *class; int real_time; + int data_field; struct Screen screen[2]; int active_screen; uint8_t cursor_row; @@ -789,11 +790,15 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp bptr = avpkt->data; for (i = 0; i < len; i += 3) { - uint8_t cc_type = *(bptr + i) & 3; + uint8_t cc_type = bptr[i] & 1; + if (validate_cc_data_pair(bptr + i)) continue; - /* ignoring data field 1 */ - if (cc_type == 1) + + if (ctx->data_field < 0) + ctx->data_field = cc_type; + + if (cc_type != ctx->data_field) continue; ret = process_cc608(ctx, bptr[i + 1] & 0x7f, bptr[i + 2] & 0x7f); @@ -861,6 +866,10 @@ static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avp #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { { "real_time", "emit subtitle events as they are decoded for real-time display", OFFSET(real_time), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, SD }, + { "data_field", "select data field", OFFSET(data_field), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, SD, "data_field" }, + { "auto", "pick first one that appears", 0, AV_OPT_TYPE_CONST, { .i64 =-1 }, 0, 0, SD, "data_field" }, + { "first", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, SD, "data_field" }, + { "second", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, SD, "data_field" }, {NULL} };
Signed-off-by: Paul B Mahol <onemda@gmail.com> --- libavcodec/ccaption_dec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)