From patchwork Wed Nov 24 15:27:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31628 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10607444iob; Wed, 24 Nov 2021 07:29:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1SXQr6tlokVr/f0tyTWldTASGk6437Bv3vF7fbIttBGfJd2LzFYXdmbGEha2cWDGuOoeH X-Received: by 2002:a05:6402:4243:: with SMTP id g3mr26529548edb.284.1637767743203; Wed, 24 Nov 2021 07:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767743; cv=none; d=google.com; s=arc-20160816; b=XT6sxHJE/BtKdp1sHdCQ3ga/YjZ9xVSZyl0NhgcOZ/A+/FRqUg5bymxH3og1YWwq0w 81mnl2lEYCTiczdor0DmZOeGgm2exTKPSz+V/x+dQ+bQtQf1gNBmJ2gxx5OsTGjcXnF2 jWvoe9IQFvuYH4/IjczGwLspe1FMedLy1QOSpSZP9xlxExIa8rJUyD3UXC+zOKnQqRBi bHn+/KlP7Q/QGvRvYQfQ7OfmL+CGl6knwbDRx/vJoIie05UPo9iFvWKPN4OfKAKet1r0 tUSeRRtDGI7KJcd+HqDD20HHGeJqCzNjpVt3s6sEMPY0eLydf8w6u6yRGz8hqB5GGnQ6 WHVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=8OeWieFvR8TYbC8PdhHkTOoqZBIPnSBJNESDWWcYQtg=; b=D8Ibjecabzk9XsSR1BQXaGRqg1xXgEGq8BOi+QO2TLHM3hmHd84pEG9tyaY5eYggnv TY3FrB0dtxM66WvLkSnlasz7nCfmG/mQXciRPIMIi0dpqfoHZLKJUuqAYSPciYK92I0z zmKCwr5kUGpnuZ8fXIcn3IdAr5KMBNTMa/PJpP1Ummd0PkOEZ99xZCf75rNoai+P+H7I pEDxhSteTr+7M/r4rAzakqdAxKsQrcy7iLn4vvtQK6yZH65gM981z25AR4CJsTPCs0UB I0ZqLUIE+4vlSbqUZRWz7pkSpUqT4STUBEWvcLOCjGZppdmP9+8GeGBfjPHEfoYqiVP/ VXPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=CwKGHxmU; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b20si412804ede.118.2021.11.24.07.29.01; Wed, 24 Nov 2021 07:29:03 -0800 (PST) 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 header.s=20210112 header.b=CwKGHxmU; 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=QUARANTINE 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 4AF9E68A03B; Wed, 24 Nov 2021 17:28:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B5A6B6881AC for ; Wed, 24 Nov 2021 17:28:50 +0200 (EET) Received: by mail-pl1-f173.google.com with SMTP id p18so2116275plf.13 for ; Wed, 24 Nov 2021 07:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LCsbXc/Pl9C5NXkZqZJ4BqUqBFRpOkTUmGzx+u+60z4=; b=CwKGHxmU4PpHYJz5Ws7aYF55Ik9t7RiOwxe39UBMs8tkhtumTJA/NHemp2kSiYXxUM gibV+HlOKMjBLTxebqQlq+xKKTWrqg/7WTk0ZynSFSrc+tAaU586a3MV63pbwGCqaQYB Vk9+Sj7lD0XUBlZ/ZszGSpFPUDXWNsh4TurC6bfqQ+MFsLmTIzKhzhqREall+MAj+aY0 vb8380VrtB9iUPw6Ougm5C2PKSHM+hLSU4rek/hg995/RYC/F/jJRcSnSaReaMJkyO4u RCOsBa8lFCfwdiQgUHzPaCE3A7PbKQYaxMUv4Dgyue6Kj8jbbNFYpcinqh7XJZZgiGb5 kq8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LCsbXc/Pl9C5NXkZqZJ4BqUqBFRpOkTUmGzx+u+60z4=; b=Rm0yVTC7H1ixvT2Fx/3yKuAk21nG7uyWHKLtIiwawdCbC3klCIuJk0lsPpBKfjGP5R bXuyciVhW+HWW4px30zmbU/ywLgigT791Ot/Lgd0giPqp+goFcqKTAQZOrDpPt3aNi/G 9IGxLcBWIzIH4PewJnEf4CXtfK+q70ymI0tZPTlK5ZBmJVNGcVIswTp0y7FZa8y5eSUP afcyrARr8YnRjWSTLoNtphNeYjt6hT/zbUezsOUmEPKa7juvcLg/JKjIUNVWnggNxZFk JzXgpxzi+oERGqvvaY3q1svRwUVTe9nSjx6GdzfxUPOBa281EMHxxKkAayaqCcAwCTP8 A2RQ== X-Gm-Message-State: AOAM530vhztEhNV9z8MYcMH9zrjVFC3+jmMVTRk74T3M01iGbrVoc/wv wgspJPrrjy3pWDax9z0M8IhsiN9aY/M= X-Received: by 2002:a17:90b:4b4d:: with SMTP id mi13mr16027379pjb.192.1637767728530; Wed, 24 Nov 2021 07:28:48 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.47 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:48 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:39 +0800 Message-Id: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 1/7] avformat/rtpdec_rfc4175: use rawvideo for uyvy422 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: pA+zQPXzKr49 From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtpdec_rfc4175.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index f50cad7..f13736b 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -55,9 +55,11 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) if (data->depth == 8) { data->pgroup = 4; pixfmt = AV_PIX_FMT_UYVY422; + stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; } else if (data->depth == 10) { data->pgroup = 5; pixfmt = AV_PIX_FMT_YUV422P10; + stream->codecpar->codec_id = AV_CODEC_ID_BITPACKED; } else { return AVERROR_INVALIDDATA; } @@ -268,7 +270,7 @@ static int rfc4175_handle_packet(AVFormatContext *ctx, PayloadContext *data, const RTPDynamicProtocolHandler ff_rfc4175_rtp_handler = { .enc_name = "raw", .codec_type = AVMEDIA_TYPE_VIDEO, - .codec_id = AV_CODEC_ID_BITPACKED, + .codec_id = AV_CODEC_ID_NONE, .priv_data_size = sizeof(PayloadContext), .parse_sdp_a_line = rfc4175_parse_sdp_line, .parse_packet = rfc4175_handle_packet, From patchwork Wed Nov 24 15:27:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31626 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10607722iob; Wed, 24 Nov 2021 07:29:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJw80ZKtNaOssi9Isf8z148A8/mn8aGKJawacSu19CnF1Z2V6+AUOmFRsmI9rova3KnkyU8U X-Received: by 2002:a17:907:72d4:: with SMTP id du20mr22246589ejc.419.1637767755017; Wed, 24 Nov 2021 07:29:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767755; cv=none; d=google.com; s=arc-20160816; b=wE9zp93TbJ1wgsjqmGSZ0yGvseLtx7efAVTiEQ/hbXqx+W8izO4ET6uVKXjeIEuHzR UCDMFoD5gZW14m4krEkOVDpsQkFAdZ/mkdUIzpExq2OuWHg9Y5U1PHJNdeRPG/7bUVrs 0tDGY0BugT+v44fCagtYauOLAw7dH6TONUbyzb8aIZU0az59B5R1eO20l6hDgLhVO3/J 263nIsOzjtgxkW5iNrFbZ5TQltI7Vg+CYyTkbhfb4ZbdT4wHI58ZXU0ogfIdhejpiirv 9Adwu/STFAQ4jDuoWRXBGEQbYcHNzZ2sY0oojKy9MHxUXzp/YCd3KKZrK27j4vV9QTDz P9pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=J6AgaSuGEXFFRZAQeAKt1kNJz2J6/YGFmcQCpHi/efU=; b=N9wlmpA5X9oAeviVmerHQPEKePqlhCXSgd4mct5J8ekci83sP3P6FlQ8Qp1l+gDVOW QRcctWzX/3VG4y4I/4Ql0tm3lSLWH/rDnq6hksVdt2RP0Gh8ynkrm8aaMM43OpjynVXq rtcfZizZYpwYqv2GGunzH00X0wy1emCnYKhH2bdF3sFIgimIJL5H01d5UG3EOtB1h3JA BqJHxRYKRCgjHtbJnLHfwlLED8BKXY97xRUDkHWE0Sj+TTnr2bBsT2p5j3HSL6XWNs+N BLbqj82F3wDrFxwfT7IOrA9CtawMFXoi+lpoeQXxx2uJES3u2+aPzTfcaG4wVhkXHirD toow== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=fq+eeIKY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z6si503376edd.85.2021.11.24.07.29.14; Wed, 24 Nov 2021 07:29:15 -0800 (PST) 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 header.s=20210112 header.b=fq+eeIKY; 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=QUARANTINE 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 AF9B268A636; Wed, 24 Nov 2021 17:29:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8372E68A05B for ; Wed, 24 Nov 2021 17:28:52 +0200 (EET) Received: by mail-pf1-f175.google.com with SMTP id b68so2971587pfg.11 for ; Wed, 24 Nov 2021 07:28:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=u+0cM0SW0M3cvko8JwlMmL+MFoVL8qfvYm+Vrznu7lQ=; b=fq+eeIKYrgv0/hkwwwY3swpeggTalgzmSRxvqdZVxrHXHJ6g8+K2kyT5qwYJF7dLYF 3Ol9pkbU9zM2WmXmdOsLRL3nNqAUhGK8Vc5e5XsNwrENC6ucLKpFATr7p3FkT8g+QROT dJaSVLBpJWzZe9NhpxJkFMXqc0v4HI2gaY4TZH7DxxkZLcj/aZFg1GYuPlr06b0WC3m+ Q84CmIfsujbvLXOI4PdcPxt/SkpszhBcJlxNmXc8zPa+htBStE8b1z8116rApH2T/vtx sr/ePgZ8nVj9Vs6qCK+aGK+e8se/azFhrmMX/7ldG/an/qVPlYNTjq5iMcxX/WI++82D QAEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u+0cM0SW0M3cvko8JwlMmL+MFoVL8qfvYm+Vrznu7lQ=; b=ktwnS2Hoj7Y9G2eYvzcY9taVEzjjtuDeRl7/XqCGK+ungeG3Go4C7R77tWnuWibrg7 JSrBM59MvPaaXzenDQ08a5f/+ZB4yFIOS5bEJK9a7pQ4PHx1Ddo90Amh5R9v6GGJdA8P gW4yG6gy5P93YgCI7dZNvokST3EvgBOOxCps3t+ClAxjUIPhxDsZEmv7gs9OrbKlGvOP BwwDdhfb4LZfNI+ZpY14Nt/i8dPoJJ3uFPTjXZo6I5naYSOrGp3Y0wYj1ihSbN2CUoWY LCo6GoI6fBq0JFo6tbkGDWUmk3YkRsDLdlJbE4/c1WuauOZbsv4vQ6f6/r9R9ojcCeos AMew== X-Gm-Message-State: AOAM531CVEtQC+7a4UOFKkMEQDmMVwXWjqubHCrbdbZJg7n+C+WcmPSI uX8bYJbC5M4THETdXyimmP6uvaTy0ds= X-Received: by 2002:a63:9e01:: with SMTP id s1mr10813670pgd.66.1637767729939; Wed, 24 Nov 2021 07:28:49 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:49 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:40 +0800 Message-Id: <1637767665-6777-2-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 2/7] avformat/rtpdec_rfc4175: support for yuv420p format X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: plw4eRQX8KhI From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtpdec_rfc4175.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index f13736b..5a7058b 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -63,6 +63,17 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) } else { return AVERROR_INVALIDDATA; } + } else if (!strncmp(data->sampling, "YCbCr-4:2:0", 11)) { + tag = MKTAG('I', '4', '2', '0'); + data->xinc = 4; + + if (data->depth == 8) { + data->pgroup = 6; + pixfmt = AV_PIX_FMT_YUV420P; + stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + } else { + return AVERROR_INVALIDDATA; + } } else { return AVERROR_INVALIDDATA; } From patchwork Wed Nov 24 15:27:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31629 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10608033iob; Wed, 24 Nov 2021 07:29:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvAlWLbEQPxsRtAEt+7CIHGW+Ip/qnljHVwryJlagt5DgQeEuJIK2MwY6taxZ4Tv7m7uZH X-Received: by 2002:a05:6402:b26:: with SMTP id bo6mr25318192edb.207.1637767767105; Wed, 24 Nov 2021 07:29:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767767; cv=none; d=google.com; s=arc-20160816; b=YxVapVbPw2S+aNq64DGTQ3IWvJzjDwAJWyaCZbbzXfDCvmTcmVr3lwKgEHVBuxaTew TCcL/SDQEZ9CwYeh5oucE9+VAYjO2a5BxAbFzllJWtM3hfIay6bSnHqK/qzdG2/Uool0 BjtMXch3powsgFydsKziH4VVcCh+UKc5frk/N/SDhBI5IaIaV/I/WjiUw5O7LPibzd7r 7vI4mXv3kSW8aNfp2JNnnCWwtZcyoRdvmVItnWo7qpiOqdjr6JW3F0vGoK97HwJIew3a qWrjGCb+TZGaQtHeN8CTBx+cpWQbE6feVJ3PmGaHr4XAmh51dLxK8jdBNtl+BFt3zc5O Cawg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=w8jIsOBvhM6yiwsxzP1KgVm3aO8awxSqZwNVeD0+9go=; b=SNjdwhE89wdIFagNgEXA6e/SSfdgEMhG2guWCW71laPyb4YN7ecc3UUcizLXaJ4b9Z NqV7ft1TJp6xm2tV0doGZ+cB9FhMoL/yxBlb+ElI4Vx6t1pZ6GZRm90oT14dL+j2+WJS sF4MM9I5L/Upn9aAyL4vBjIo/4Ig8xNyaAQgY3ur8tXCq3MMn6ZxXoIDSfQulQte8G91 +ciLhME+ZC1HT6Z8G9IRAzSaoPfu6v63JNfZeS+SGSCGPYlw6+BUjGY4+uiJzY+qaNbW +VJdD+vNqMAfqv9vCBeFJF8ftM+jGN2b5kLhS4P3gU9FU3XqwcY8gm9chGQFL7b6+Ejd o4jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b="COKk/+lY"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y15si201772ejp.478.2021.11.24.07.29.26; Wed, 24 Nov 2021 07:29:27 -0800 (PST) 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 header.s=20210112 header.b="COKk/+lY"; 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=QUARANTINE 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 B9FCA68A8F5; Wed, 24 Nov 2021 17:29:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 75D2A689DEB for ; Wed, 24 Nov 2021 17:28:53 +0200 (EET) Received: by mail-pj1-f53.google.com with SMTP id y14-20020a17090a2b4e00b001a5824f4918so5335127pjc.4 for ; Wed, 24 Nov 2021 07:28:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1fkzh5gJrUnYAzYrgAxJVyvpwf5sME2Aj4if9fVfgEY=; b=COKk/+lYx5QzkGvHMNAeVXQYR3iGJHB/+LWImG6XrreRvuQ5Jiw9JP++E+mqlLRznG 2RVZbV+oskw57HztlkaNHxTdMWMGBSAt//VnfdUKn5BL74O2vZRKTC39XnfjWR30Rbli hNBRmrmIjMPy5oiu4OzC2C/j3xsUWRPtz4VcyjZJqt0D3oASL4KCZfyCJdVk5djnZ8PH VJqbOoNiq9MvKXnMwWZdszcgp8f97VBMg3aHRwURHhHqTa1Ur9E6nEInHRuk+dvNVIzg fDOZE+QMYQQzsK51jc8BakJajeY8IRXlz9Ctmw+dGlCKU5W9tF+96TW8Pblx0NKGCwp5 6bLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1fkzh5gJrUnYAzYrgAxJVyvpwf5sME2Aj4if9fVfgEY=; b=AkXe7RVfHPzfxagIh3PNiRpZkcCSczOG5+MRfjE0j0cmOzDynL3M6iPdh60BAPDf/U 9aTx4WfybbPqy8npr+PwVMU3nFkNF+I0wWfKUn0rLMQWaKQu01NNAdVzGj9kXW88HP16 Zg+487Bb2M9+kxA+cTjJ4JZscHZe9qbVb9sMswl6a4OmmfvXxxyBneYuP6re7YApK3fk vK0wcHE0e5TVGQ0k8IFlW/Iy2pHKTqS1Sf8ry6AyWxLJAcWO4UpbGPQ7YoefZ9yEMvnK 5i2n725kkt1SY65abqKLlAU8tgfVqXIRpa0jANvdQiM4K3LyDaIRgiT/DJ392Tm9uCL5 rvUg== X-Gm-Message-State: AOAM533F6NfB9zG2cwqfPbLSy4C0GnS8CUeN+S/m3DdvbJxh1bcC/a23 6wR7itZqgisbwgPyrq3Lu+RGEee6dUU= X-Received: by 2002:a17:90b:3a85:: with SMTP id om5mr17127213pjb.28.1637767731493; Wed, 24 Nov 2021 07:28:51 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:51 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:41 +0800 Message-Id: <1637767665-6777-3-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 3/7] avformat/rtpenc: adds partial support for the RFC 4175 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: O7j2SupXOjOv From: Limin Wang Signed-off-by: Limin Wang --- Changelog | 1 + libavformat/Makefile | 1 + libavformat/rtpenc.c | 4 ++ libavformat/rtpenc.h | 1 + libavformat/rtpenc_rfc4175.c | 116 +++++++++++++++++++++++++++++++++++++++++++ libavformat/sdp.c | 25 ++++++++++ libavformat/version.h | 2 +- 7 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 libavformat/rtpenc_rfc4175.c diff --git a/Changelog b/Changelog index 31a0d5e..2035c27 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ version : - varblur video filter - huesaturation video filter - colorspectrum source video filter +- RTP packetizer for uncompressed video (RFC 4175) version 4.4: diff --git a/libavformat/Makefile b/libavformat/Makefile index 3d6c8ef..a19d2e0 100644 --- a/libavformat/Makefile +++ b/libavformat/Makefile @@ -482,6 +482,7 @@ OBJS-$(CONFIG_RTP_MUXER) += rtp.o \ rtpenc_jpeg.o \ rtpenc_mpv.o \ rtpenc.o \ + rtpenc_rfc4175.o \ rtpenc_vc2hq.o \ rtpenc_vp8.o \ rtpenc_vp9.o \ diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 2a1c176..4f115cc 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -84,6 +84,7 @@ static int is_supported(enum AVCodecID id) case AV_CODEC_ID_MJPEG: case AV_CODEC_ID_SPEEX: case AV_CODEC_ID_OPUS: + case AV_CODEC_ID_RAWVIDEO: return 1; default: return 0; @@ -619,6 +620,9 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) case AV_CODEC_ID_MJPEG: ff_rtp_send_jpeg(s1, pkt->data, size); break; + case AV_CODEC_ID_RAWVIDEO: + ff_rtp_send_raw_rfc4175 (s1, pkt->data, size); + break; case AV_CODEC_ID_OPUS: if (size > s->max_payload_size) { av_log(s1, AV_LOG_ERROR, diff --git a/libavformat/rtpenc.h b/libavformat/rtpenc.h index 62dc9ab..70ea85b 100644 --- a/libavformat/rtpenc.h +++ b/libavformat/rtpenc.h @@ -95,6 +95,7 @@ void ff_rtp_send_vc2hq(AVFormatContext *s1, const uint8_t *buf, int size, int in void ff_rtp_send_vp8(AVFormatContext *s1, const uint8_t *buff, int size); void ff_rtp_send_vp9(AVFormatContext *s1, const uint8_t *buff, int size); void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buff, int size); +void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size); const uint8_t *ff_h263_find_resync_marker_reverse(const uint8_t *av_restrict start, const uint8_t *av_restrict end); diff --git a/libavformat/rtpenc_rfc4175.c b/libavformat/rtpenc_rfc4175.c new file mode 100644 index 0000000..6fa34b6 --- /dev/null +++ b/libavformat/rtpenc_rfc4175.c @@ -0,0 +1,116 @@ +/* + * RTP Packetization of RAW video (RFC4175) + * Copyright (c) 2021 Limin Wang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include "rtpenc.h" + +void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size) +{ + RTPMuxContext *s = s1->priv_data; + int width = s1->streams[0]->codecpar->width; + int height = s1->streams[0]->codecpar->height; + int xinc, yinc, pgroup; + int field = 0; + int i = 0; + int offset = 0; + + s->timestamp = s->cur_timestamp; + switch (s1->streams[0]->codecpar->format) { + case AV_PIX_FMT_UYVY422: + xinc = yinc = 2; + pgroup = 4; + break; + case AV_PIX_FMT_YUV420P: + xinc = yinc = 4; + pgroup = 6; + break; + default: + return; + } + + while (i < height) { + int left = s->max_payload_size; + uint8_t *dest = s->buf; + uint8_t *headers; + const int head_size = 6; + int next_line; + int length, cont, pixels; + + /* Extended Sequence Number */ + *dest++ = 0; + *dest++ = 0; + left -= 2; + + headers = dest; + do { + pixels = width * xinc - offset; + length = (pixels * pgroup) / xinc; + + left -= head_size; + if (left >= length) { + next_line = 1; + } else { + pixels = (left / pgroup) * xinc; + length = (pixels * pgroup) / xinc; + next_line = 0; + } + left -= length; + + /* Length */ + *dest++ = (length >> 8) & 0xff; + *dest++ = length & 0xff; + + /* Line No */ + *dest++ = ((i >> 8) & 0x7f) | ((field << 7) & 0x80); + *dest++ = i & 0xff; + if (next_line) i += yinc; + + cont = (left > (head_size + pgroup) && i < height) ? 0x80 : 0x00; + /* Offset and Continuation marker */ + *dest++ = ((offset >> 8) & 0x7f) | cont; + *dest++ = offset & 0xff; + + if (next_line) + offset = 0; + else + offset += pixels; + } while (cont); + + do { + int l_line; + int l_off; + int copy_offset; + + length = (headers[0] << 8) | headers[1]; + l_line = ((headers[2] & 0x7f) << 8) | headers[3]; + l_off = ((headers[4] & 0x7f) << 8) | headers[5]; + cont = headers[4] & 0x80; + headers += head_size; + + copy_offset = (l_line * width + l_off) * pgroup / xinc; + if (copy_offset + length > size) + break; + memcpy (dest, buf + copy_offset, length); + dest += length; + } while (cont); + + ff_rtp_send_data (s1, s->buf, s->max_payload_size - left, i >= height); + } +} diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 1200e55..cc04d70 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -660,6 +660,31 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int p->width, p->height, pix_fmt, config); break; } + case AV_CODEC_ID_RAWVIDEO: { + const char *pix_fmt; + int bit_depth = 8; + + switch (p->format) { + case AV_PIX_FMT_UYVY422: + pix_fmt = "YCbCr-4:2:2"; + break; + case AV_PIX_FMT_YUV420P: + pix_fmt = "YCbCr-4:2:0"; + break; + default: + av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); + return NULL; + } + + av_strlcatf(buff, size, "a=rtpmap:%d raw/90000\r\n" + "a=fmtp:%d sampling=%s; " + "width=%d; height=%d; " + "depth=%d\r\n", + payload_type, payload_type, + pix_fmt, p->width, p->height, bit_depth); + break; + } + case AV_CODEC_ID_VP8: av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n", payload_type); diff --git a/libavformat/version.h b/libavformat/version.h index ae2b873..0705ee4 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -33,7 +33,7 @@ // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 59 #define LIBAVFORMAT_VERSION_MINOR 9 -#define LIBAVFORMAT_VERSION_MICRO 101 +#define LIBAVFORMAT_VERSION_MICRO 102 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ LIBAVFORMAT_VERSION_MINOR, \ From patchwork Wed Nov 24 15:27:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31625 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10608389iob; Wed, 24 Nov 2021 07:29:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJypaGAGSPA4aPq8+iKNlZAO2AZH9jiW+fRdpjx6zdeELKXZynuNk9p72OpJoc61+gRg4wYm X-Received: by 2002:a05:6402:4248:: with SMTP id g8mr26526707edb.182.1637767779017; Wed, 24 Nov 2021 07:29:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767779; cv=none; d=google.com; s=arc-20160816; b=zD2tKkN9XmOoMlAoc+kRKsb0pFrg0X21dZipR6UqtoSj1JFUFCM9aRWh/XApP8BArZ MlWaSiBtq9WjD9OJ6lr3hSurzdOaJYoKUFxTxE0B7Ky8c+juV7GwR8Xnpf7C840AFtyb 492m2ts9iXe64qdoh2eNuTqZUyGx4xchECgEaDHn1vRm9XfznGdyFKdCG0wh2FaKGF54 7GbFJP7Fde18PBBByTu9KOegI80+8ceGlWxerJ147C/SNZn4sEa39BZDKxdQTvY9T+On tH98bE/BDzLAkdnRQ4oT49RSrIFQ7zeC/iphGhwySwP9OEd7SUi1tcUDBeyIYepTr44Y 4bcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=K9mmHZomnRLojmVWRRgV0U6kMBZpyOh0E59UTwF+Qv0=; b=LW9kSka8zhQQc3E04pJqRewLVvQi8S0KRTlk5lNgEnRGMznr0865akZxonxKe/3xEL 6KH9QbHBOB9IpJnakzYlUdRczYsjlqMnLEexU4tsPVS7doEyoqFuUeaP+gbOG9dMYmGa MQCjgTFYU6Cj9VUWlDVidJfUxrDQbt6GkqeCp7bKvA/MqJ22JCjbAlIjmDXfgSAT1nHN VGErA5WJq8TzoqBEXqwn4w+A1tcVz1GRLYR4irLO5dIlPamO1WkWGfKqCFGbFMI+CNsf 0tsHgS5J23kY6yvJCZdNYj2GS4pXd8AzFXOdgCH1ofSiRMdb2HxrrEb5Sb4BIT//PDtd m13g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=nP2cxJ+s; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hc16si244683ejc.214.2021.11.24.07.29.38; Wed, 24 Nov 2021 07:29:38 -0800 (PST) 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 header.s=20210112 header.b=nP2cxJ+s; 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=QUARANTINE 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 2E22568ABD1; Wed, 24 Nov 2021 17:29:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1860768A5AF for ; Wed, 24 Nov 2021 17:28:55 +0200 (EET) Received: by mail-pl1-f172.google.com with SMTP id o14so2147640plg.5 for ; Wed, 24 Nov 2021 07:28:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Tg9RKVX1FA5m9ZWGl4cUpkI37tkD8bfD+dhiKP4taU=; b=nP2cxJ+sTiqlEnapk0oNl2pD9iaswjeYDiJA+RbhgDzY6PpiSED3SqWQmweWVfU3ap vTDCHP7pv9uPSfTroh2FYpo4s51GQ/RLMNAUVBYQSAnztvW2Yyh6ajBXD9pKMwYDYGYm 4L5/udScPnrNc0E8pzJRTMsG3Eq6Znm8zbvHD8/kKB3T3/QtAEA1SbqK5Cb6NJPoWz+E jnvfbWHMRVNtKL+AcASKjhb3a9B2a3AYmjAmpUiPq1QfDKnA8wapMEQLnZZp+3SQLWnj hUfeGXz9tV69cm0D2No2dBZ3SoC0o1EZ4J4Vecp/fRpbX5kGxI/fuHMp7n5M/3l3dBYL SjXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7Tg9RKVX1FA5m9ZWGl4cUpkI37tkD8bfD+dhiKP4taU=; b=YUW4iFnw4amPYoeXCfqOR3dE/qu/0ixyxcwOsf/zTYT+2deOAPS/NMLGTMoxM0ZroV hVycsQ0hxpzIpCmgk2DGAAJilJRXiDOhFMFdPiIWG8UlIFjA2ZzBk7VitBGmSdJ7G8zt zSMx0aU/H2CmvwpYReyJ8Lg3s01hk9j4i/T8oIw4u5flXZs0C/VjOI/HZPnTLDSKoq3F QUtd7jCjBKLFhdOiyG7H/nJbJli+ifTQ8svTyQRWNSZRjlOypKz+cwdRkUZACAda4p/y sW8J/zVwBiUDSCENeCQzAqUqgX4XuWImttEpyz5dGHs9KWxWggtguFp88ec6QyeBHV13 BAKA== X-Gm-Message-State: AOAM5332iaLS21E9di+dwW8X2bAsT0/KOQ9xXKmSmNeJIoGEzRHpzdkm oPZ7wnZaenqpcvT4bwTFY1HVIsDDP7M= X-Received: by 2002:a17:90b:1a87:: with SMTP id ng7mr16582401pjb.86.1637767732898; Wed, 24 Nov 2021 07:28:52 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:52 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:42 +0800 Message-Id: <1637767665-6777-4-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 4/7] avcodec: rename bitpacked.c to bitpacked_dec.c X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 4MQa93YrSDjq From: Limin Wang Signed-off-by: Limin Wang --- libavcodec/Makefile | 2 +- libavcodec/bitpacked.c | 158 --------------------------------------------- libavcodec/bitpacked_dec.c | 158 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 159 insertions(+), 159 deletions(-) delete mode 100644 libavcodec/bitpacked.c create mode 100644 libavcodec/bitpacked_dec.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 14fbd2e..fbb2b79 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -243,7 +243,7 @@ OBJS-$(CONFIG_BINK_DECODER) += bink.o binkdsp.o OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o OBJS-$(CONFIG_BINTEXT_DECODER) += bintext.o cga_data.o -OBJS-$(CONFIG_BITPACKED_DECODER) += bitpacked.o +OBJS-$(CONFIG_BITPACKED_DECODER) += bitpacked_dec.o OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmvaudio.o diff --git a/libavcodec/bitpacked.c b/libavcodec/bitpacked.c deleted file mode 100644 index 0440df9..0000000 --- a/libavcodec/bitpacked.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Unpack bit-packed streams to formats supported by FFmpeg - * Copyright (c) 2017 Savoir-faire Linux, Inc - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* Development sponsored by CBC/Radio-Canada */ - -/** - * @file - * Bitpacked - */ - -#include "avcodec.h" -#include "internal.h" -#include "get_bits.h" -#include "libavutil/imgutils.h" - -struct BitpackedContext { - int (*decode)(AVCodecContext *avctx, AVFrame *frame, - const AVPacket *pkt); -}; - -/* For this format, it's a simple passthrough */ -static int bitpacked_decode_uyvy422(AVCodecContext *avctx, AVFrame *frame, - const AVPacket *avpkt) -{ - int ret; - - /* there is no need to copy as the data already match - * a known pixel format */ - frame->buf[0] = av_buffer_ref(avpkt->buf); - if (!frame->buf[0]) { - return AVERROR(ENOMEM); - } - - ret = av_image_fill_arrays(frame->data, frame->linesize, avpkt->data, - avctx->pix_fmt, avctx->width, avctx->height, 1); - if (ret < 0) { - av_buffer_unref(&frame->buf[0]); - return ret; - } - - return 0; -} - -static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame, - const AVPacket *avpkt) -{ - uint64_t frame_size = (uint64_t)avctx->width * (uint64_t)avctx->height * 20; - uint64_t packet_size = (uint64_t)avpkt->size * 8; - GetBitContext bc; - uint16_t *y, *u, *v; - int ret, i, j; - - ret = ff_get_buffer(avctx, frame, 0); - if (ret < 0) - return ret; - - if (frame_size > packet_size) - return AVERROR_INVALIDDATA; - - if (avctx->width % 2) - return AVERROR_PATCHWELCOME; - - ret = init_get_bits(&bc, avpkt->data, avctx->width * avctx->height * 20); - if (ret) - return ret; - - for (i = 0; i < avctx->height; i++) { - y = (uint16_t*)(frame->data[0] + i * frame->linesize[0]); - u = (uint16_t*)(frame->data[1] + i * frame->linesize[1]); - v = (uint16_t*)(frame->data[2] + i * frame->linesize[2]); - - for (j = 0; j < avctx->width; j += 2) { - *u++ = get_bits(&bc, 10); - *y++ = get_bits(&bc, 10); - *v++ = get_bits(&bc, 10); - *y++ = get_bits(&bc, 10); - } - } - - return 0; -} - -static av_cold int bitpacked_init_decoder(AVCodecContext *avctx) -{ - struct BitpackedContext *bc = avctx->priv_data; - - if (!avctx->codec_tag || !avctx->width || !avctx->height) - return AVERROR_INVALIDDATA; - - if (avctx->codec_tag == MKTAG('U', 'Y', 'V', 'Y')) { - if (avctx->bits_per_coded_sample == 16 && - avctx->pix_fmt == AV_PIX_FMT_UYVY422) - bc->decode = bitpacked_decode_uyvy422; - else if (avctx->bits_per_coded_sample == 20 && - avctx->pix_fmt == AV_PIX_FMT_YUV422P10) - bc->decode = bitpacked_decode_yuv422p10; - else - return AVERROR_INVALIDDATA; - } else { - return AVERROR_INVALIDDATA; - } - - return 0; -} - -static int bitpacked_decode(AVCodecContext *avctx, void *data, int *got_frame, - AVPacket *avpkt) -{ - struct BitpackedContext *bc = avctx->priv_data; - int buf_size = avpkt->size; - AVFrame *frame = data; - int res; - - frame->pict_type = AV_PICTURE_TYPE_I; - frame->key_frame = 1; - - res = bc->decode(avctx, frame, avpkt); - if (res) - return res; - - *got_frame = 1; - return buf_size; - -} - -const AVCodec ff_bitpacked_decoder = { - .name = "bitpacked", - .long_name = NULL_IF_CONFIG_SMALL("Bitpacked"), - .type = AVMEDIA_TYPE_VIDEO, - .id = AV_CODEC_ID_BITPACKED, - .priv_data_size = sizeof(struct BitpackedContext), - .init = bitpacked_init_decoder, - .decode = bitpacked_decode, - .capabilities = AV_CODEC_CAP_EXPERIMENTAL, - .codec_tags = (const uint32_t []){ - MKTAG('U', 'Y', 'V', 'Y'), - FF_CODEC_TAGS_END, - }, - .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, -}; diff --git a/libavcodec/bitpacked_dec.c b/libavcodec/bitpacked_dec.c new file mode 100644 index 0000000..0440df9 --- /dev/null +++ b/libavcodec/bitpacked_dec.c @@ -0,0 +1,158 @@ +/* + * Unpack bit-packed streams to formats supported by FFmpeg + * Copyright (c) 2017 Savoir-faire Linux, Inc + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Development sponsored by CBC/Radio-Canada */ + +/** + * @file + * Bitpacked + */ + +#include "avcodec.h" +#include "internal.h" +#include "get_bits.h" +#include "libavutil/imgutils.h" + +struct BitpackedContext { + int (*decode)(AVCodecContext *avctx, AVFrame *frame, + const AVPacket *pkt); +}; + +/* For this format, it's a simple passthrough */ +static int bitpacked_decode_uyvy422(AVCodecContext *avctx, AVFrame *frame, + const AVPacket *avpkt) +{ + int ret; + + /* there is no need to copy as the data already match + * a known pixel format */ + frame->buf[0] = av_buffer_ref(avpkt->buf); + if (!frame->buf[0]) { + return AVERROR(ENOMEM); + } + + ret = av_image_fill_arrays(frame->data, frame->linesize, avpkt->data, + avctx->pix_fmt, avctx->width, avctx->height, 1); + if (ret < 0) { + av_buffer_unref(&frame->buf[0]); + return ret; + } + + return 0; +} + +static int bitpacked_decode_yuv422p10(AVCodecContext *avctx, AVFrame *frame, + const AVPacket *avpkt) +{ + uint64_t frame_size = (uint64_t)avctx->width * (uint64_t)avctx->height * 20; + uint64_t packet_size = (uint64_t)avpkt->size * 8; + GetBitContext bc; + uint16_t *y, *u, *v; + int ret, i, j; + + ret = ff_get_buffer(avctx, frame, 0); + if (ret < 0) + return ret; + + if (frame_size > packet_size) + return AVERROR_INVALIDDATA; + + if (avctx->width % 2) + return AVERROR_PATCHWELCOME; + + ret = init_get_bits(&bc, avpkt->data, avctx->width * avctx->height * 20); + if (ret) + return ret; + + for (i = 0; i < avctx->height; i++) { + y = (uint16_t*)(frame->data[0] + i * frame->linesize[0]); + u = (uint16_t*)(frame->data[1] + i * frame->linesize[1]); + v = (uint16_t*)(frame->data[2] + i * frame->linesize[2]); + + for (j = 0; j < avctx->width; j += 2) { + *u++ = get_bits(&bc, 10); + *y++ = get_bits(&bc, 10); + *v++ = get_bits(&bc, 10); + *y++ = get_bits(&bc, 10); + } + } + + return 0; +} + +static av_cold int bitpacked_init_decoder(AVCodecContext *avctx) +{ + struct BitpackedContext *bc = avctx->priv_data; + + if (!avctx->codec_tag || !avctx->width || !avctx->height) + return AVERROR_INVALIDDATA; + + if (avctx->codec_tag == MKTAG('U', 'Y', 'V', 'Y')) { + if (avctx->bits_per_coded_sample == 16 && + avctx->pix_fmt == AV_PIX_FMT_UYVY422) + bc->decode = bitpacked_decode_uyvy422; + else if (avctx->bits_per_coded_sample == 20 && + avctx->pix_fmt == AV_PIX_FMT_YUV422P10) + bc->decode = bitpacked_decode_yuv422p10; + else + return AVERROR_INVALIDDATA; + } else { + return AVERROR_INVALIDDATA; + } + + return 0; +} + +static int bitpacked_decode(AVCodecContext *avctx, void *data, int *got_frame, + AVPacket *avpkt) +{ + struct BitpackedContext *bc = avctx->priv_data; + int buf_size = avpkt->size; + AVFrame *frame = data; + int res; + + frame->pict_type = AV_PICTURE_TYPE_I; + frame->key_frame = 1; + + res = bc->decode(avctx, frame, avpkt); + if (res) + return res; + + *got_frame = 1; + return buf_size; + +} + +const AVCodec ff_bitpacked_decoder = { + .name = "bitpacked", + .long_name = NULL_IF_CONFIG_SMALL("Bitpacked"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_BITPACKED, + .priv_data_size = sizeof(struct BitpackedContext), + .init = bitpacked_init_decoder, + .decode = bitpacked_decode, + .capabilities = AV_CODEC_CAP_EXPERIMENTAL, + .codec_tags = (const uint32_t []){ + MKTAG('U', 'Y', 'V', 'Y'), + FF_CODEC_TAGS_END, + }, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, +}; From patchwork Wed Nov 24 15:27:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31630 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10608696iob; Wed, 24 Nov 2021 07:29:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJwetZdPd21YSILZSXKggiWE+dF+bQ+Y2EhtQFecutDR+3j7hCpomAtdv9Ype9Ibm9Sq98qq X-Received: by 2002:a17:906:7ccf:: with SMTP id h15mr21009127ejp.386.1637767791758; Wed, 24 Nov 2021 07:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767791; cv=none; d=google.com; s=arc-20160816; b=tw+Qyj9D2V1F0NakRvo1VnGfuV7tkuaLkl9Rtyps8tvZTjoNVuMaQBwPF/blHt4w+0 mpMwxfqkLgdLvokFwPb4UFl2f5ZZ5y/qZE6CYgFtKSqkmcadaC5/aPBmgw3YbzeoL/i6 Bb8VQrHV60npd14t+XJytYWo+sdnnpy6/3OIeM0r/C7fY3XkL1eD4FLHkfn4kbAr5krF bLAELI45ygAbnPb+Xba2/W+CDf5+xqSIs5Y5Nmgol6xUKwYTxWxo8sSWMPiFQjmffGWi eVHelLE6kAA90sQgqC0XdXNJvnx7R9H9xfwBaiWfsN4S7TQ1tIKFPqmkLXD7He/Gz4VT eboQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=gnezIR5kzcahpslym0xLfP3yLfoecj7IuZ2tRc2OHHE=; b=RIym82bGhlHDBkhMWITlNlj5jBQhat3v7c4uOn0hYD9ybH9QK1tAiHx/XAOu0WwU27 SG+aZNNlvAQ6QZCK75M8QJ6fGsXhzYlyNvgio1GdzmT7GmYzlapv6taMkcoE7qeILCdk zWDdDSYQ+6YAEnTu5rvpp6hSNYdDQtjvGA9Yp/Yy6nFCbS4+n1n9MCDdGD98/LLHmbc/ 8lzmXvTVpLAMTWy3JWwapP5bTrTamk6lpRC5eGaacOVTZS2XlcqDjQLgaHux8q0aHb48 j4bNPQ8s++g6UCS3rWkG2TtADSkms58yeRLVWrTWQp3V6+yrcwuJRXA/uo+c2kpyHpnk 1ehg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=V1muKAvE; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i1si233270ejw.736.2021.11.24.07.29.50; Wed, 24 Nov 2021 07:29:51 -0800 (PST) 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 header.s=20210112 header.b=V1muKAvE; 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=QUARANTINE 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 3876568ACFD; Wed, 24 Nov 2021 17:29:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3521C68A7B8 for ; Wed, 24 Nov 2021 17:28:56 +0200 (EET) Received: by mail-pj1-f42.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so4487808pjj.0 for ; Wed, 24 Nov 2021 07:28:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oiDzAM7eA2b6mzv3/WcFgO87uoWC88FD7SP1YEO8ECk=; b=V1muKAvEHKMBsENTJV4eDcN4WvzGgB4QXbIoU14g6Ax8PGdt366A4aM+4hYBZkaola v/e/im+rtWKglwcWZ5mrTbTUtjQdxWy6zL7hFK3iCpGAiFU6x/fz2397djfRefGBsQZZ ipzvNR03pVI3tfeL82f+JIUGdMB0v1U0O8uhbg3OORyb01utIi1OJTU7C9Y5t7zmLFfF Kf5vc+hE9phn61qTyJrS33T6xlsufcdwuRmX96AkEL+FIxmynknnFGwsga4/JyiLNiXq Dpf58XCQ0t+1qtN7Vuaw7sBToDYtnffz1vJMs6PBF22F+Iq9ILmqrZmZODFUM1YSG/QK IvkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oiDzAM7eA2b6mzv3/WcFgO87uoWC88FD7SP1YEO8ECk=; b=osSYLFqAPi+Dt2uTu4kUwjQXBrsnIQOoIH7lXtVXGYILTCc68GdSL3E56QlH0Kfm8O Pnne3M/9HBX8wAbMVn7zCBDN46G05bCGy5OQR8c7FZf1GBYhDn1/dl5gZTlL06eG5jf9 HmKETB79jyXmOs+8FXjlYiY44U9gDKpddvnmh7B3KzUIharTfRmR4SfT49xDEw8hIA/T jObHdryVoGW75bx6Adwzw2/F2DAdG5k8X6PZxpIAS8tG17nzwxItYGfDpn0JtmH9iOTD YxgS4KdXvs0X9Ddhyo5wglNf+7yVoDRVjEv2RuFEcDUJdpnYbA6mJDhyILbnTt8NOBgQ VHcg== X-Gm-Message-State: AOAM531AVGI41zUi/B2uRXiQpHy9QE9OwE9byYIZf/P7syDlCO4vrC00 1pzhAXYF7kMZap80arYlmFcv2T6i3x4= X-Received: by 2002:a17:903:245:b0:143:c5ba:8bd8 with SMTP id j5-20020a170903024500b00143c5ba8bd8mr19989144plh.64.1637767734388; Wed, 24 Nov 2021 07:28:54 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:54 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:43 +0800 Message-Id: <1637767665-6777-5-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 5/7] avcodec: suppport for bitpacked encode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Vi92IIOebU5c From: Limin Wang Signed-off-by: Limin Wang --- Changelog | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/bitpacked_enc.c | 121 +++++++++++++++++++++++++++++++++++++++++++++ libavcodec/version.h | 2 +- 5 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 libavcodec/bitpacked_enc.c diff --git a/Changelog b/Changelog index 2035c27..a66231b4 100644 --- a/Changelog +++ b/Changelog @@ -32,6 +32,7 @@ version : - huesaturation video filter - colorspectrum source video filter - RTP packetizer for uncompressed video (RFC 4175) +- bitpacked encoder version 4.4: diff --git a/libavcodec/Makefile b/libavcodec/Makefile index fbb2b79..6be90cd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -244,6 +244,7 @@ OBJS-$(CONFIG_BINKAUDIO_DCT_DECODER) += binkaudio.o OBJS-$(CONFIG_BINKAUDIO_RDFT_DECODER) += binkaudio.o OBJS-$(CONFIG_BINTEXT_DECODER) += bintext.o cga_data.o OBJS-$(CONFIG_BITPACKED_DECODER) += bitpacked_dec.o +OBJS-$(CONFIG_BITPACKED_ENCODER) += bitpacked_enc.o OBJS-$(CONFIG_BMP_DECODER) += bmp.o msrledec.o OBJS-$(CONFIG_BMP_ENCODER) += bmpenc.o OBJS-$(CONFIG_BMV_AUDIO_DECODER) += bmvaudio.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 9ede09b..89d6526 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -65,6 +65,7 @@ extern const AVCodec ff_bethsoftvid_decoder; extern const AVCodec ff_bfi_decoder; extern const AVCodec ff_bink_decoder; extern const AVCodec ff_bitpacked_decoder; +extern const AVCodec ff_bitpacked_encoder; extern const AVCodec ff_bmp_encoder; extern const AVCodec ff_bmp_decoder; extern const AVCodec ff_bmv_video_decoder; diff --git a/libavcodec/bitpacked_enc.c b/libavcodec/bitpacked_enc.c new file mode 100644 index 0000000..a8cad64 --- /dev/null +++ b/libavcodec/bitpacked_enc.c @@ -0,0 +1,121 @@ +/* + * bitpacked encoder + * + * Copyright (c) 2021 Limin Wang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avcodec.h" +#include "encode.h" +#include "internal.h" +#include "put_bits.h" +#include "libavutil/pixdesc.h" + +struct BitpackedContext { + int (*encode)(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame); +}; + +static int encode_yuv422p10(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame) +{ + const int buf_size = avctx->height * avctx->width * avctx->bits_per_coded_sample / 8; + int ret; + uint8_t *dst; + const uint16_t *y; + const uint16_t *u; + const uint16_t *v; + PutBitContext pb; + const int depth = avctx->bits_per_raw_sample; + + ret = ff_get_encode_buffer(avctx, pkt, buf_size, 0); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); + return ret; + } + dst = pkt->data; + + init_put_bits(&pb, dst, buf_size); + + for (int i = 0; i < avctx->height; i++) { + y = (uint16_t*)(frame->data[0] + i * frame->linesize[0]); + u = (uint16_t*)(frame->data[1] + i * frame->linesize[1]); + v = (uint16_t*)(frame->data[2] + i * frame->linesize[2]); + + for (int j = 0; j < avctx->width; j += 2) { + /* u, y0, v, y1 */ + put_bits(&pb, depth, av_clip_uintp2(*u++, depth)); + put_bits(&pb, depth, av_clip_uintp2(*y++, depth)); + put_bits(&pb, depth, av_clip_uintp2(*v++, depth)); + put_bits(&pb, depth, av_clip_uintp2(*y++, depth)); + } + } + flush_put_bits(&pb); + + return 0; +} + + +static av_cold int encode_init(AVCodecContext *avctx) +{ + struct BitpackedContext *s = avctx->priv_data; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); + const int depth = desc->comp[0].depth; + + if (avctx->width & 1) { + av_log(avctx, AV_LOG_ERROR, "bitpacked needs even width\n"); + return AVERROR(EINVAL); + } + + avctx->bits_per_coded_sample = av_get_bits_per_pixel(desc); + avctx->bits_per_raw_sample = depth; + avctx->bit_rate = ff_guess_coded_bitrate(avctx); + + if (avctx->pix_fmt == AV_PIX_FMT_YUV422P10) + s->encode = encode_yuv422p10; + else + return AVERROR(EINVAL); + + return 0; +} + +static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + struct BitpackedContext *s = avctx->priv_data; + int ret; + + ret = s->encode(avctx, pkt, frame); + if (ret) + return ret; + + *got_packet = 1; + return 0; +} + +const AVCodec ff_bitpacked_encoder = { + .name = "bitpacked", + .long_name = NULL_IF_CONFIG_SMALL("Bitpacked"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_BITPACKED, + .priv_data_size = sizeof(struct BitpackedContext), + .capabilities = AV_CODEC_CAP_DR1, + .init = encode_init, + .encode2 = encode_frame, + .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV422P10, + AV_PIX_FMT_NONE }, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, +}; diff --git a/libavcodec/version.h b/libavcodec/version.h index 4d30003..58e3322 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 59 #define LIBAVCODEC_VERSION_MINOR 13 -#define LIBAVCODEC_VERSION_MICRO 100 +#define LIBAVCODEC_VERSION_MICRO 101 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ From patchwork Wed Nov 24 15:27:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31624 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10608993iob; Wed, 24 Nov 2021 07:30:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxGeFum2wivr9pJzXhiD171GRGHh0aRxhZmP7nOL10PuZStnzaLC6kPeu7zo4drzpYCWe3 X-Received: by 2002:a50:8d47:: with SMTP id t7mr26307542edt.14.1637767802533; Wed, 24 Nov 2021 07:30:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767802; cv=none; d=google.com; s=arc-20160816; b=0NatlGV9tRqDaCWb8emLx46nXKvutgxCfWxS7oDVUrcwVsTPN3znb0oIhZWJNxDuRn J12gEjDGzzIaz+aqFP9RiWrR8pRGSXQAx3hTdJShrxWKMqNiG0ivMXqxwBwO/0yaimK8 L53zw9mjVe5X4+juzaGKQHCRmJWD9AZnPeLuB5dLcUjFfIH+0aF3cx4azPzgzBSqT7zt oa+Y4tf7OzapF/txPQ+2S5tPejbGcqJC+HzAXCsUyaP5UHEWGsukfQRXmymBtfZ+8Ytz BNsKf56JaxHAubYVW/cYSSuQzLinkj/4NFNLKto2gq1BxupP4TC20alugJxLcqgeXO16 7HUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=5eRfnHY5Kz3YWWd0zeTHfhdfgKp9Ovsqc/ewN0yPkIM=; b=q9vfxNoQMCwXzj+/Qr9POcijjlxGzg1M7tluZTdgv/c1poeZbQxQhqJRAoGhbMdGeo 9tQEltes8KTL23iilX2RrTHtCJOJyHQWBiktYhlJ+J4TvlbR+DJtqHADst+pxnJaMor5 4eNO9l0MRx1sGzCEIji/bP7JfDFo2GIOQfWP7E5SyjestUJCQCuWhwzy7GT2MINZM2N9 HC7H0Px1XDgSY4mC5osOCtvz53FVdX/dM7cyX/IhMqYdzBWnLpUejn6zlCb6QqDyEguu Vkw4Pv5YrezuJBbP8wi5ieh2p+0+b+AaFF7A0RczQ5CP4Wjd2jbApYcC1qAi1rdrwDOg CUPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=i7orGvq4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id n8si501875edx.93.2021.11.24.07.30.02; Wed, 24 Nov 2021 07:30:02 -0800 (PST) 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 header.s=20210112 header.b=i7orGvq4; 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=QUARANTINE 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 4E5FC68AD5F; Wed, 24 Nov 2021 17:29:08 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB622689DEB for ; Wed, 24 Nov 2021 17:28:57 +0200 (EET) Received: by mail-pl1-f177.google.com with SMTP id k4so2128576plx.8 for ; Wed, 24 Nov 2021 07:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=74PvtctsdkBFsmMIv/HdMD7HdlOjHjGqhgVw+O6hknM=; b=i7orGvq4xtw0FQbFiJPvYLcG/rPc6HMwv7Ttp/hQm4yhjDRTpCn/lU9+qr1LFcyct7 Une39DxBwGdJCz+NDJKhlndWZWy4Hc1QyI7s8fZ1xlKOh/M9yWEGph/5BG4nhfdFayO4 6KrYRoIl+czYWh3qVDK+tOvJaQ/f6m+BmNpEm0+8fl5qX2vgNDkJMHN7PPRCC/5694+d uPOeQyFB4Ft0cBasqiYPW8hzndyLyOqyokRFDsoHHV8fSWzIdlq8bkNIFBO70Gs7Ts3r wzv9ALwqJ2BQIjXgld4GhrTsG2urQyFOcDqq4uVRUawt7WCh+jSYY+WtY2QYnFepdHlJ SNTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=74PvtctsdkBFsmMIv/HdMD7HdlOjHjGqhgVw+O6hknM=; b=QhBZsdmRARf6gtA1iD7Hm4kNmH9AIy+sV5W0I9GSt7n//mCYjKZtESKTjPNmc0Q2Ac t+UvB2Kh/Ql8C6MoPhmrUtE3eDUbdqPtWrS69LGgZKId8xWZQ1yVSLC8YoI5IGB6gBFW O9GzhveelShZZ6K2zIxfnW3xSg2xKojiqFKUj+Tmox8DZkNdwwavLw8OL5Cz9Rcn5V3o 4knoJjpnQysLXZ4sfFsgdvoIOdctDm+/8drw7Dhbisl8e4VRatBt5De+fsJc2Eyl9HpF cwmUSfoUgMtzgxttf8b7n0Or8emCIMWKk1+CmWKAaSG2oGILJgUP/VO+0rSRxHqtdamj 1cyA== X-Gm-Message-State: AOAM533X/zjz2HDoCfbVqPIaZ0JPqnrGdMdhvpMnITi3h6l9v92Pcn/L NvjF9QPls2tuyE1v2cN9lWPOvfIuAdk= X-Received: by 2002:a17:902:e5d0:b0:141:cdfe:97d7 with SMTP id u16-20020a170902e5d000b00141cdfe97d7mr19234388plf.65.1637767736016; Wed, 24 Nov 2021 07:28:56 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:55 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:44 +0800 Message-Id: <1637767665-6777-6-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 6/7] avformat: suppport for 4:2:2 10-bit for rfc4175 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: OSnJlFejamT4 From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtpenc.c | 2 ++ libavformat/rtpenc_rfc4175.c | 4 ++++ libavformat/sdp.c | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c index 4f115cc..17f5d9d 100644 --- a/libavformat/rtpenc.c +++ b/libavformat/rtpenc.c @@ -85,6 +85,7 @@ static int is_supported(enum AVCodecID id) case AV_CODEC_ID_SPEEX: case AV_CODEC_ID_OPUS: case AV_CODEC_ID_RAWVIDEO: + case AV_CODEC_ID_BITPACKED: return 1; default: return 0; @@ -620,6 +621,7 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) case AV_CODEC_ID_MJPEG: ff_rtp_send_jpeg(s1, pkt->data, size); break; + case AV_CODEC_ID_BITPACKED: case AV_CODEC_ID_RAWVIDEO: ff_rtp_send_raw_rfc4175 (s1, pkt->data, size); break; diff --git a/libavformat/rtpenc_rfc4175.c b/libavformat/rtpenc_rfc4175.c index 6fa34b6..4623b4a 100644 --- a/libavformat/rtpenc_rfc4175.c +++ b/libavformat/rtpenc_rfc4175.c @@ -37,6 +37,10 @@ void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size) xinc = yinc = 2; pgroup = 4; break; + case AV_PIX_FMT_YUV422P10: + xinc = yinc = 2; + pgroup = 5; + break; case AV_PIX_FMT_YUV420P: xinc = yinc = 4; pgroup = 6; diff --git a/libavformat/sdp.c b/libavformat/sdp.c index cc04d70..5ad2a54 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -660,6 +660,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int p->width, p->height, pix_fmt, config); break; } + case AV_CODEC_ID_BITPACKED: case AV_CODEC_ID_RAWVIDEO: { const char *pix_fmt; int bit_depth = 8; @@ -668,6 +669,10 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int case AV_PIX_FMT_UYVY422: pix_fmt = "YCbCr-4:2:2"; break; + case AV_PIX_FMT_YUV422P10: + pix_fmt = "YCbCr-4:2:2"; + bit_depth = 10; + break; case AV_PIX_FMT_YUV420P: pix_fmt = "YCbCr-4:2:0"; break; From patchwork Wed Nov 24 15:27:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lance Wang X-Patchwork-Id: 31627 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp10609302iob; Wed, 24 Nov 2021 07:30:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBiu/bo9ZDFCyExspG51PHANh7LrlRjtPYWVh7AMP/hKXQXpoVrbFlNJy8v5DqE4tlWypQ X-Received: by 2002:a05:6402:2692:: with SMTP id w18mr25970844edd.220.1637767815030; Wed, 24 Nov 2021 07:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637767815; cv=none; d=google.com; s=arc-20160816; b=DM3l9elD7YYjMMt4sUn80OWfScAimjFsVIK9+hJeZ/EhkOxWB/D5A8ZhEz8aIC3FtV +IHEe2J0eDVeExrLi1OttHCWHZ0PlSFJUIC439mJSUc7z9XwqsCdMSWDYoMjLiwgtP3y Es261/kdF9VTNtj8YpsbgkqgIvL6H111gg7tAcb5WVGtv1zo+vZ4o6MzNhEioLNN3yt+ CPtRBl+R16kQCBtlwOhlC/2xyfgQTGABP3E4XlH9yMt/Pp2vpCeguzDSoUpJDmpoNuS1 4ASQk9u7WASSt2mJXUPK4kg/8zfL0riJpimIv6lJjfl0CSYVr7dY36SXeuXxSAafcKu3 cADA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=en+dJ+nnmSENta4xkbbXHuKI9xTSt55UQd6CKSlpEow=; b=EtfnRf+9XSpRntBeH7CwEPBEKeRCSnXwvnc72BrDI0GO7AFPXkJyzhfNZz7tYKpgER 0P9FhEGy7GNo0AIecQ+mA2X5GGftQdEkuBrliUX1VDVmNvZBPRKuq0YnjNR7yALRKRPT Xcav2JZ4M29CPuOd7nxF8cuyCD1PDPf+QsBguYZhkwrjVHUBz/HF8mQbCddym4A15DKD HTB/4ph+C8mGLIEzlm4d0gDqJu7vaNjli/y8a3m6gA27Vo9MvmmkVGE7/FowS238RRnu jrE283vkiGBsJUT0PNb3btBji0EmTCPjrPxD7wI5IjBttRPGc0SSJTqhL9VDh+dKWXMg cOkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=Qf41T5Pt; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hc19si247015ejc.688.2021.11.24.07.30.14; Wed, 24 Nov 2021 07:30:15 -0800 (PST) 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 header.s=20210112 header.b=Qf41T5Pt; 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=QUARANTINE 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 5681868ADB0; Wed, 24 Nov 2021 17:29:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6295C68AC48 for ; Wed, 24 Nov 2021 17:28:59 +0200 (EET) Received: by mail-pf1-f178.google.com with SMTP id b68so2971970pfg.11 for ; Wed, 24 Nov 2021 07:28:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=V7mxJL4jMCbMgUNhMMxBIL0Scz/a5Y/TuukWmK25cmg=; b=Qf41T5PtafI3RU/iK5qj7Bb4NG1LHCHeVBRSSc5iRLvL/9VboFQcb+KjlRpL309Vbr zjOQQ8R0QYtZRhXw/GJA6TJoO8bGzoPumF0S4SqMs6azk16pUpN7wZh+YFicoheOb0J4 gWcpWgxdgaJM5NWOjgPibqZib7FBz3IAceul59gImyp3ioGIRkeq0oUVWGAD+IJhta2l KGOaiqCilowUjhgJQTDGSehw8RkUIvUAxRzj4lVWkw62P4AdpjGMLRj3ctVT3c3ARrEQ GXLVvX9oCdz9dpHJi0UmY3OXUKexNsb/g2QbEnivNm0aw8qikrEH4IhWwg74i5MWYJIT n4Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V7mxJL4jMCbMgUNhMMxBIL0Scz/a5Y/TuukWmK25cmg=; b=E5AuSuTuRjKxZZat4gcHr+KWSTr5BJzIAUUeHng0kjoMN3Gnuuf+RszPrTN4ANguFa r6Wc5qyA5q4sTTI2m4596x6Srqm+Ubcj7FWg77rrBfep5aTybebNDALRYW4RiwAr5LoH Ik4+FEQlZgfxZYFHhXGkpMmMZftS2vj9GULLD6MBCVU8i3elgS2X1b4QO3tRM/HmR8Ln q19wffH6TpYQz9ZAOkVo1Vo5Am0iBEV0EqW4Ek70gxGohmffkTvh0RjD5PgZBlDj/srQ jPo4DUECPy1XDKCqdMAC0P5LiDSRp7A73nFGlLf6YGGom3DkO0Ovaq6yU/dxANRGTr3N x/2g== X-Gm-Message-State: AOAM533DT3XKQ20uoZ0YwRp+EVTCXhvB+MyItozkRRQ3MDHJc6netusk MgYLlLVB+lZmxwWcmBc9uq7jWYZlcdo= X-Received: by 2002:a05:6a00:1741:b0:49f:99e6:1d1d with SMTP id j1-20020a056a00174100b0049f99e61d1dmr7142484pfc.34.1637767737584; Wed, 24 Nov 2021 07:28:57 -0800 (PST) Received: from vpn2.localdomain ([161.117.202.209]) by smtp.gmail.com with ESMTPSA id b6sm83842pfm.170.2021.11.24.07.28.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Nov 2021 07:28:57 -0800 (PST) From: lance.lmwang@gmail.com To: ffmpeg-devel@ffmpeg.org Date: Wed, 24 Nov 2021 23:27:45 +0800 Message-Id: <1637767665-6777-7-git-send-email-lance.lmwang@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> References: <1636712536-13114-1-git-send-email-lance.lmwang@gmail.com> <1637767665-6777-1-git-send-email-lance.lmwang@gmail.com> Subject: [FFmpeg-devel] [PATCH v3 7/7] avformat/rtp: support for RGB/BGR for rfc4175 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Cc: Limin Wang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: HsZT7XKT91Ri From: Limin Wang Signed-off-by: Limin Wang --- libavformat/rtpdec_rfc4175.c | 20 ++++++++++++++++++++ libavformat/rtpenc_rfc4175.c | 8 ++++++++ libavformat/sdp.c | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c index 5a7058b..7feefd2 100644 --- a/libavformat/rtpdec_rfc4175.c +++ b/libavformat/rtpdec_rfc4175.c @@ -74,6 +74,26 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data) } else { return AVERROR_INVALIDDATA; } + } else if (!strncmp(data->sampling, "RGB", 3)) { + tag = MKTAG('R', 'G', 'B', 24); + if (data->depth == 8) { + data->xinc = 1; + data->pgroup = 3; + pixfmt = AV_PIX_FMT_RGB24; + stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + } else { + return AVERROR_INVALIDDATA; + } + } else if (!strncmp(data->sampling, "BGR", 3)) { + tag = MKTAG('B', 'G', 'R', 24); + if (data->depth == 8) { + data->xinc = 1; + data->pgroup = 3; + pixfmt = AV_PIX_FMT_BGR24; + stream->codecpar->codec_id = AV_CODEC_ID_RAWVIDEO; + } else { + return AVERROR_INVALIDDATA; + } } else { return AVERROR_INVALIDDATA; } diff --git a/libavformat/rtpenc_rfc4175.c b/libavformat/rtpenc_rfc4175.c index 4623b4a..ea4c370 100644 --- a/libavformat/rtpenc_rfc4175.c +++ b/libavformat/rtpenc_rfc4175.c @@ -45,6 +45,14 @@ void ff_rtp_send_raw_rfc4175(AVFormatContext *s1, const uint8_t *buf, int size) xinc = yinc = 4; pgroup = 6; break; + case AV_PIX_FMT_RGB24: + xinc = yinc = 1; + pgroup = 3; + break; + case AV_PIX_FMT_BGR24: + xinc = yinc = 1; + pgroup = 3; + break; default: return; } diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 5ad2a54..a41c2cf 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -676,6 +676,12 @@ static char *sdp_write_media_attributes(char *buff, int size, AVStream *st, int case AV_PIX_FMT_YUV420P: pix_fmt = "YCbCr-4:2:0"; break; + case AV_PIX_FMT_RGB24: + pix_fmt = "RGB"; + break; + case AV_PIX_FMT_BGR24: + pix_fmt = "BGR"; + break; default: av_log(fmt, AV_LOG_ERROR, "Unsupported pixel format.\n"); return NULL;