[FFmpeg-cvslog] avcodec/ccaption_dec: allow selection of second field captions
Paul B Mahol
git at videolan.org
Sat Jun 20 16:12:44 EEST 2020
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Jun 19 16:16:28 2020 +0200| [bbd0be04d09b9d49440ca7d69774aa4483de6022] | committer: Paul B Mahol
avcodec/ccaption_dec: allow selection of second field captions
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bbd0be04d09b9d49440ca7d69774aa4483de6022
---
libavcodec/ccaption_dec.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index e67a47508c..73f762ef82 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 (ctx->data_field < 0)
+ ctx->data_field = cc_type;
+
if (validate_cc_data_pair(bptr + i))
continue;
- /* ignoring data field 1 */
- if (cc_type == 1)
+
+ 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}
};
More information about the ffmpeg-cvslog
mailing list