From patchwork Sun Oct 2 21:18:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 38528 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp964020pzh; Sun, 2 Oct 2022 14:18:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43QMdOkMrr35Iz4ShaTJe4rCtmMoHYwczOGi0jc81y30iqTw0ZJEKm5b2nqE8R7LsGQfjS X-Received: by 2002:a17:907:2d8b:b0:781:c864:fffd with SMTP id gt11-20020a1709072d8b00b00781c864fffdmr12727579ejc.681.1664745529685; Sun, 02 Oct 2022 14:18:49 -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 cr19-20020a170906d55300b0078333d9f17bsi7264120ejc.819.2022.10.02.14.18.49; Sun, 02 Oct 2022 14:18:49 -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=@outlook.com header.s=selector1 header.b=f479aAiJ; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4DA9968BBC7; Mon, 3 Oct 2022 00:18:40 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-oln040092075047.outbound.protection.outlook.com [40.92.75.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E055B68BA2B for ; Mon, 3 Oct 2022 00:18:33 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CBfFbnlV2zhHmpPp5VJkgJwFkV+3ZAWY5yHO1kertAygLC8BUM2tAIkcOj4HwX8Lc3aRG07KdTntDMlKjwsJS7MXbObWePdbuoWdMpz9ty/Fs3zlJwq94hU6H5vhsXmNjGy3o//2XW3CO7IZWpWE0EeFJuOriRpbp5huE/SEGNHHsw2BQoNor1QyiYwCI638p1W2fLBLQ1zk7CUMzCFKi4/Epx8WS4kvhMXFGIlEPhR1GNphOuIoO1eDCzMjWEnGXhyaVqsVat9JhhAN3Kkb82zR8c1O8fiRwuB230EBOw0kajM1f0Xqy3hlWBFqXuOAf7DexNkALMajzEGoU9NoLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9zdSPYfydJd4d9vMlNPGbcRrhwDV/GxKLEj5F0ObqpA=; b=Ljw+a0Xg+DMpaZK5rej8b5IpnQMYIIFNl8rDXzmm7JVWRH1cvMKTN9YpEFXqu9oWnZZ96hAhjBh2WAHyXCSyhYiljlSanLXiXbwqh5UF+JOwS7/v5Cny2RhrhSnW+5OCmEJs12AfH0Aw9b00xUUPmPxdD6ieZK8Fc/fxloU74ZwJ71BPpHT5KWwcYuTXpVkeSwMDOM0Prku9TKCQwiLD8snq9tIecVavE3onRh4CWvJ/7E82e62Y/TvO5UriMaDpbArvyoYpnrGVS6cfQqtbSO/60shIOczcM/Enqp/Bt/IX/MndhJWqSOznkp/VaPmSKkQRsl55kLQzw/hyQHS64g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9zdSPYfydJd4d9vMlNPGbcRrhwDV/GxKLEj5F0ObqpA=; b=f479aAiJLa2tBPUzzD7HqoMkBil8NJ2TzUEcQe7IOFIFPe7sCG1O078bJqPa1902sui5HmcVuCLunAn7c9lMf3qX6OT6dQfo1LGo7V7x+Qpm9ldV4xZA7Bm+zSeq+2ci8vll+vGtVzw/j3GaJYyVX/OAbdnHux9L39SOtGmfreA9lcnufU1BcHX4QOzKxBX33hQZxOG68HTUZ3zlu43Qelk0AH6vtag3WKfBQV1KV2J1UaFCL+X+TtsLmSsMp/s9ZeXIe0o0Ki5Atu/cf5tL6339pKAgh3Qvzv+3iSKnw5kExNl2zC3Henyd0MvWUQMmaMyMR9J57btgZj6A0sAURQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by PR3P250MB0290.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Sun, 2 Oct 2022 21:18:24 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::68bd:2fc7:ac52:38f8%9]) with mapi id 15.20.5676.023; Sun, 2 Oct 2022 21:18:24 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 2 Oct 2022 23:18:14 +0200 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [lxhVcZqduOu2B+pNfrUVXGWR2v16/zXAx6KJtzTYhn0=] X-ClientProxiedBy: ZR0P278CA0180.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::7) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20221002211815.959423-4-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|PR3P250MB0290:EE_ X-MS-Office365-Filtering-Correlation-Id: 4234aaaf-5c5a-4348-80a1-08daa4bba431 X-MS-Exchange-SLBlob-MailProps: AZnQBsB9Xmq9S+lyC0Rq4VBpsdMYmcOkqsHEA97O2r7mXHp7+itzaFGsOyfDnVPa3PmyiDJPjIq5RmfcYRqkHFHaVuYlSZXDkZ9kGcMS5EgKkkpGqz22XCpPiPijhv7MU4rg4zkacXDi4vtvCe9n5zBCdwRqx/JA4qSYG5E2grhq/BQ7qygk9KdlJxMX/GlIPoCGkRthUSN2AMR4CmiqSYh7YNSdoI9jvSnJ0Tjs5vS6tofo9wsMiNXpEJC0X8e2P/NYAUb0qjvucCpeAryRK0voOCuK4HEeUrzGcbjl2uetctn9KF5rURXbDnoByGYT4InnHY0PVV2Rdo68HXDcNZnT8XESt/C25v+TAOaF/zgmZLDlvsPER6uAf4s2DCxr8QwQPGhMqttSoR+kNS0rm+bkwaxOC964CkCEdIovm7m/AutHEbq4cuJrJAubNpq/Cza95YBY9Wny+axnv29jeiBssOgb2jSIxR5ItcK1/0Py/cDSlbrLemoSX/GVE//dsyMhlYUZ+JVEiJ/1lsm4PF3mLqIIq2+JLGKO3O0Bp7kQAOgiGc/rireT0NHOYA577IJ/5uFCn4+U6tX18wBXXalIz7jd8hYPcLELVdG04XMSTmiKajvLyWej6t4hZYBZW4TmKqsNS1gkQ033ddkoOzyZml7zcDUnEcqfk5IJ2uiIzXv1rjJlVCb9QK9XAKPKKC5i3AhzP9x4PYICJWwBXLBSc1yTW8IlUADSNAZac2TQEKzxfIPiftBwFfsVI2hAeV85DHFg9QY= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H8VerVHvfg3vjRYZiwiY22kCxNBnrAX0iD0g9P/uV6Gb6bGx4JkNRlkoELmMjUTtCjrsIktDK5uSrGW/zmprlNFh7sDdEfKHqfBftr/gr0H/7KgUfgNG2YkjM1jEZv8z7gbzS4AnWekOsY1yl4oq1yNl6dwNgBaogKWinkpSedL5QzRGkcivfcO2RVg6llsVrielYRMlFeeDxsMMHpUtSHh4yfXdkdvfQQLZ9kXI11t91tobhJOdRrPau7QMSpvHnXBYJrjmjBDc5u7k3321V8ohxs6FXUyx2E7Q/XL4BmGsUN2igiMKgH23/awZgB9TlhlWvrVywZRgdzW2vM7iMnHe9iHi+RhVnJSU2j2S4TSbCeB/qjizq1SH/VxfeL8uXXyUOXqNsd6Twq6ycTwzMSWTEfI0Q218Pl0jAwoPwvkVY7By0YXdefblQgYZHmuNfqER1iprZ05wMP0FlNlzkuibSAJ19OBIh/VdV2BA+B8dRFLa2no1N95K990X45+LUDJNEOiBasTujQ+yxf75BFGGX5ndUJ99oKiXDDDLITlSEaHUDmKs0QRavriBq1Nw+dTTCn7zjDsl6VA4GBc9rP2lPDg9PQvsvHhGtllViOzdcCqm+B7JZPlaJ2WzhOYNXJWiid3XnOP0pqjpSykyU5IwNqodl6XQHakW/vyEFVkVcqKZhceqT69kNYqBzycF X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GqJZCoK+9lVxkmPe0sYmdOlB+SCV7Uaw9W9RkkPYKptk9k2DuEbwhRJDBnkjca41NgxvYKUhecuN/benwUi3z/HJB3FUL02HaY60lWWvOKP+jw8JrFvMuhatYp0X8E88xVncqOpR2ENhqKX+ITQKmAkPbEPFd8NWiQmAOnU689vQ5psPnmPIePVnb1fNt1jU8CpopRAfkvNgoauv2dJGlWZ1xT797pdzGzPyU8TDxVEOl+goLPwyz9yTm3rVtQ5uUdZJ6I6EvKr9pnhW9bD7TousHyGF3SMtpziWT+KjySkIUngacPH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message-Id: 4234aaaf-5c5a-4348-80a1-08daa4bba431 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Oct 2022 21:18:24.8612 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3P250MB0290 Subject: [FFmpeg-devel] [PATCH 5/6] avcodec/h261enc: Store the H.261 format value 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ZjH1WJkxETUw Signed-off-by: Andreas Rheinhardt --- libavcodec/h261enc.c | 39 +++++++++++++++------------------------ libavcodec/h261enc.h | 1 - 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 7aa548c39d..e8ea357cbb 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -46,25 +46,16 @@ typedef struct H261EncContext { H261Context common; int gob_number; + enum { + H261_QCIF = 0, + H261_CIF = 1, + } format; } H261EncContext; -int ff_h261_get_picture_format(int width, int height) -{ - // QCIF - if (width == 176 && height == 144) - return 0; - // CIF - else if (width == 352 && height == 288) - return 1; - // ERROR - else - return AVERROR(EINVAL); -} - void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) { H261EncContext *const h = (H261EncContext *)s; - int format, temp_ref; + int temp_ref; align_put_bits(&s->pb); @@ -81,18 +72,13 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) put_bits(&s->pb, 1, 0); /* camera off */ put_bits(&s->pb, 1, s->pict_type == AV_PICTURE_TYPE_I); /* freeze picture release on/off */ - format = ff_h261_get_picture_format(s->width, s->height); - - put_bits(&s->pb, 1, format); /* 0 == QCIF, 1 == CIF */ + put_bits(&s->pb, 1, h->format); /* 0 == QCIF, 1 == CIF */ put_bits(&s->pb, 1, 1); /* still image mode */ put_bits(&s->pb, 1, 1); /* reserved */ put_bits(&s->pb, 1, 0); /* no PEI */ - if (format == 0) - h->gob_number = -1; - else - h->gob_number = 0; + h->gob_number = h->format - 1; s->mb_skip_run = 0; } @@ -102,7 +88,7 @@ void ff_h261_encode_picture_header(MpegEncContext *s, int picture_number) static void h261_encode_gob_header(MpegEncContext *s, int mb_line) { H261EncContext *const h = (H261EncContext *)s; - if (ff_h261_get_picture_format(s->width, s->height) == 0) { + if (h->format == H261_QCIF) { h->gob_number += 2; // QCIF } else { h->gob_number++; // CIF @@ -118,6 +104,7 @@ static void h261_encode_gob_header(MpegEncContext *s, int mb_line) void ff_h261_reorder_mb_index(MpegEncContext *s) { + const H261EncContext *const h = (H261EncContext*)s; int index = s->mb_x + s->mb_y * s->mb_width; if (index % 11 == 0) { @@ -129,7 +116,7 @@ void ff_h261_reorder_mb_index(MpegEncContext *s) /* for CIF the GOB's are fragmented in the middle of a scanline * that's why we need to adjust the x and y index of the macroblocks */ - if (ff_h261_get_picture_format(s->width, s->height) == 1) { // CIF + if (h->format == H261_CIF) { s->mb_x = index % 11; index /= 11; s->mb_y = index % 3; @@ -387,7 +374,11 @@ av_cold int ff_h261_encode_init(MpegEncContext *s) H261EncContext *const h = (H261EncContext*)s; static AVOnce init_static_once = AV_ONCE_INIT; - if (ff_h261_get_picture_format(s->width, s->height) < 0) { + if (s->width == 176 && s->height == 144) { + h->format = H261_QCIF; + } else if (s->width == 352 && s->height == 288) { + h->format = H261_CIF; + } else { av_log(s->avctx, AV_LOG_ERROR, "The specified picture size of %dx%d is not valid for the " "H.261 codec.\nValid sizes are 176x144, 352x288\n", diff --git a/libavcodec/h261enc.h b/libavcodec/h261enc.h index 088cd9f4e0..102e994494 100644 --- a/libavcodec/h261enc.h +++ b/libavcodec/h261enc.h @@ -30,7 +30,6 @@ #include "mpegvideo.h" -int ff_h261_get_picture_format(int width, int height); void ff_h261_reorder_mb_index(MpegEncContext *s); void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y);