From patchwork Tue Mar 21 17:08:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John P Poet X-Patchwork-Id: 3047 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.50.79 with SMTP id y76csp1994079vsy; Tue, 21 Mar 2017 10:16:25 -0700 (PDT) X-Received: by 10.28.45.214 with SMTP id t205mr4091210wmt.15.1490116585788; Tue, 21 Mar 2017 10:16:25 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j2si28724049wra.66.2017.03.21.10.16.25; Tue, 21 Mar 2017 10:16:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 141CA6891D3; Tue, 21 Mar 2017 19:16:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot0-f171.google.com (mail-ot0-f171.google.com [74.125.82.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1515F680114 for ; Tue, 21 Mar 2017 19:15:57 +0200 (EET) Received: by mail-ot0-f171.google.com with SMTP id i1so155847406ota.3 for ; Tue, 21 Mar 2017 10:16:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=NkpLKJeg+HXhukC+go/U3ZGfePaYjtHmhSGAEgIDQyc=; b=ortdRfYmuy/xLqMKSGC7asldHHYHs7bXRMMj/ACgXxVWXdcXNWlvUFZsocmGP3E6oP bk2oF+7PnKk6qmYh/pSGbN2/rtrexeZBt5QE0r0YgYtNwdPIdsFo6ugdH83hI1prcyjE klSQeNlpi5zyjiiirZB6I4XNcx3ueWUAHlK0BxSG3/WwR5YditUdbVVtKLZQe4g0V9ZH TdB9F2Bplfiz3bGBhuqKE5MyZ6ajD34CWEjWiCYoPaS6ZiczjEUDK4fFPYAdeKnaP1tw dYy4Ey71rQ1/MYN0Nw+KXCAOjotP4Le4ODyhAlBUpcQtjwZEbbM4SyLC0iVzmheZW+kY +apg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=NkpLKJeg+HXhukC+go/U3ZGfePaYjtHmhSGAEgIDQyc=; b=L4/YPBrMW9zitIIgokcePzbl9g0Mrg4gdiUAOIwhVXLz3LhjB7Ve8vDBahMSrw0Er1 fuSXps+T+OyT+epnnzN1Wr6OJQenvooaygAewYFKenud5tE8EGqCA0q85fo6kTeO92hL oLRVF70vu39NVjLg+/g9I47sguNlQNRratEIzbY7kipya5ybrOuN0Gg+A6vkdnWfP2kw PKxeP+d5s/LxClJZE9zQx7h01tDDlFWxxqLREZHcf9ANCtfVZ61mQMKjX8Uww9gvOeoG 8qB5sus+2UnqPeH298c+70fnM6FHiFLWMe1BA8F4hXN7bZpWCzc4DzOexCa5/0tUb5sd hCxA== X-Gm-Message-State: AFeK/H39vo2atRlBsJGoCL86Maz/QjQRLMDb7y7FzgplmsqrTHVP0sNUkiFKbFBheUOH+5zEnEmaqJC3K4FPmA== X-Received: by 10.157.48.167 with SMTP id s39mr21137775otc.108.1490116120691; Tue, 21 Mar 2017 10:08:40 -0700 (PDT) MIME-Version: 1.0 From: John P Poet Date: Tue, 21 Mar 2017 17:08:29 +0000 Message-ID: To: ffmpeg-devel@ffmpeg.org X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] Add A53 closed captions to mpeg picture header. 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" If AV_FRAME_DATA_A53_CC "user data" is available, encode it into the mpeg picture header. This follows the spec in section 6.2.3 of http://atsc.org/wp-content/uploads/2015/03/a_53-Part-4-2009.pdf I am working on gstreamer side, to inject the information into the ffmpeg side data, and have it generally working. It would also be trivial to add "AV_FRAME_DATA_A53_BAR", but I don't currently have a way to test that. John From 6c835804b4eaacc27272667d197b63eb76f8d41c Mon Sep 17 00:00:00 2001 From: John Poet Date: Tue, 21 Mar 2017 10:02:10 -0600 Subject: [PATCH] Add A53 closed captions to mpeg picture header. If AV_FRAME_DATA_A53_CC "user data" is available, encode it into the mpeg picture header. --- libavcodec/mpeg12enc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index f45598a..b33e8be 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -543,6 +543,23 @@ void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number) } } + side_data = av_frame_get_side_data(s->current_picture_ptr->f, + AV_FRAME_DATA_A53_CC); + if (side_data) { + avpriv_align_put_bits(&s->pb); + put_header(s, USER_START_CODE); + put_bits(&s->pb, 8, 'G'); // ATSC_user_data + put_bits(&s->pb, 8, 'A'); + put_bits(&s->pb, 8, '9'); + put_bits(&s->pb, 8, '4'); + + put_bits(&s->pb, 8, 0x03); // MPEG_cc_data + + for(int idx = 0; idx < side_data->size; ++idx) { + put_bits(&s->pb, 8, side_data->data[idx]); + } + } + s->mb_y = 0; ff_mpeg1_encode_slice_header(s); } -- 2.1.4