From patchwork Mon Aug 10 15:49:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 21583 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 2C2F244A9A5 for ; Mon, 10 Aug 2020 18:50:19 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 055DB68974F; Mon, 10 Aug 2020 18:50:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6ED086880F0 for ; Mon, 10 Aug 2020 18:50:12 +0300 (EEST) Received: by mail-qk1-f195.google.com with SMTP id 2so8731415qkf.10 for ; Mon, 10 Aug 2020 08:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7z/AlBt5lPIYuXEyQrEMqnbIys/BN2DBObCYZh9PVws=; b=fcQHOLxRlyvbYe9f/iPSCyOI9BpU8+zc12YHrnnYbsRAMyE9chrx7DCWrZzfItrksG PRAm8aPUTcA3Zx0qWfh3NzWYnP+2UPc3QjhVr9O6MrpLU7H+y3/S6LjBWu1O0sFRgtAF E7bbFnelekswHmZpzP4WicLvCdEHfARR9h43bRdIA2u/Jg+UBMzSyIw00I7JjNcYLA5F nWTklWOtX4abCNhYSa6we+WnMZ8UTRVJaRZLfIEWehsiwFhKWiDs1SKTdhMHzKHEQGv/ 8d+7LHYaLZrZH3qOD/TnsBYH/LgEm+KCRqHjFnkqJI7QOLt9yek/ZhljxtPUEdRUur// zB8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7z/AlBt5lPIYuXEyQrEMqnbIys/BN2DBObCYZh9PVws=; b=fd78+/Mk5OYL86mrlGgsWJ8Qv2DE5dt1HwmE2srCsP8FP8lp2o/wNN5J44tU1cvnSa MloRq6MhnjS/pTW9b8mkVd2/eU49ect0ZRnwGIiqsVbF+vsqdOsU/KYx0swt/9uzU7Lm T+uLulsM1bzWB91PPz764f/B2Ki5uuxT5lfxOBWR96kIiekovqMxRrb/VeOUh+DumvBY WpUu3JiWLAPlFOg6dHgn/eXA+07XZ0j0kdvaMrOlU604ifDVzJnVxeEtBBcQFiDypn00 DW9tpAh/Fw9UtCADW94h+OJbRAvhFfM6rXrDd8PLctpjdCJt+xwTHS0vckLGQMCdHIRG H4gQ== X-Gm-Message-State: AOAM532lrml7DkcmYfdGSCEO/v6Xy+iV8QntMiMZrcxxDV33Vul7vOhz Kzp5AxVAQr1QSJER9KvFlhMwUavl X-Google-Smtp-Source: ABdhPJx6ESUyP7tl9KbA8OjOhW/tEUlQZ0+VeBpQCm8wi/fOqt8bef3sPw5hXr8Ik4GFFdxIW1R4tg== X-Received: by 2002:a37:a293:: with SMTP id l141mr27157805qke.222.1597074610282; Mon, 10 Aug 2020 08:50:10 -0700 (PDT) Received: from localhost.localdomain ([181.23.72.45]) by smtp.gmail.com with ESMTPSA id o15sm13793249qkk.95.2020.08.10.08.50.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Aug 2020 08:50:09 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 10 Aug 2020 12:49:38 -0300 Message-Id: <20200810154941.4988-2-jamrial@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200810154941.4988-1-jamrial@gmail.com> References: <20200810154941.4988-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/libdav1d: add support for A53 Closed Captions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- configure | 3 ++- libavcodec/libdav1d.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 37fe01e8be..83f051fdee 100755 --- a/configure +++ b/configure @@ -3211,6 +3211,7 @@ libcelt_decoder_deps="libcelt" libcodec2_decoder_deps="libcodec2" libcodec2_encoder_deps="libcodec2" libdav1d_decoder_deps="libdav1d" +libdav1d_decoder_select="atsc_a53" libdavs2_decoder_deps="libdavs2" libfdk_aac_decoder_deps="libfdk_aac" libfdk_aac_encoder_deps="libfdk_aac" @@ -6328,7 +6329,7 @@ enabled libcelt && require libcelt celt/celt.h celt_decode -lcelt0 && die "ERROR: libcelt must be installed and version must be >= 0.11.0."; } enabled libcaca && require_pkg_config libcaca caca caca.h caca_create_canvas enabled libcodec2 && require libcodec2 codec2/codec2.h codec2_create -lcodec2 -enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.4.0" "dav1d/dav1d.h" dav1d_version +enabled libdav1d && require_pkg_config libdav1d "dav1d >= 0.5.0" "dav1d/dav1d.h" dav1d_version enabled libdavs2 && require_pkg_config libdavs2 "davs2 >= 1.6.0" davs2.h davs2_decoder_open enabled libdc1394 && require_pkg_config libdc1394 libdc1394-2 dc1394/dc1394.h dc1394_new enabled libdrm && require_pkg_config libdrm libdrm xf86drm.h drmGetVersion diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index 132d344296..fd801c6fd5 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -26,7 +26,9 @@ #include "libavutil/imgutils.h" #include "libavutil/opt.h" +#include "atsc_a53.h" #include "avcodec.h" +#include "bytestream.h" #include "decode.h" #include "internal.h" @@ -364,6 +366,34 @@ FF_ENABLE_DEPRECATION_WARNINGS light->MaxCLL = p->content_light->max_content_light_level; light->MaxFALL = p->content_light->max_frame_average_light_level; } + if (p->itut_t35) { + GetByteContext gb; + unsigned int user_identifier; + + bytestream2_init(&gb, p->itut_t35->payload, p->itut_t35->payload_size); + bytestream2_skip(&gb, 1); // terminal provider code + bytestream2_skip(&gb, 1); // terminal provider oriented code + user_identifier = bytestream2_get_be32(&gb); + switch (user_identifier) { + case MKBETAG('G', 'A', '9', '4'): { // closed captions + AVBufferRef *buf = NULL; + + res = ff_parse_a53_cc(&buf, gb.buffer, bytestream2_get_bytes_left(&gb)); + if (res < 0) + goto fail; + if (!res) + break; + + if (!av_frame_new_side_data_from_buf(frame, AV_FRAME_DATA_A53_CC, buf)) + av_buffer_unref(&buf); + + c->properties |= FF_CODEC_PROPERTY_CLOSED_CAPTIONS; + break; + } + default: // ignore unsupported identifiers + break; + } + } res = 0; fail: