Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2020-06-19 17:16:28 +0300
committerPaul B Mahol <onemda@gmail.com>2020-06-20 16:07:26 +0300
commitbbd0be04d09b9d49440ca7d69774aa4483de6022 (patch)
treed69997868b8525adfb084353ede0a6c8f89b7e51 /libavcodec/ccaption_dec.c
parentc6791a32b4574feff18e3ca5180d69157336759a (diff)
avcodec/ccaption_dec: allow selection of second field captions
Diffstat (limited to 'libavcodec/ccaption_dec.c')
-rw-r--r--libavcodec/ccaption_dec.c15
1 files 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}
};