From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 01/11] lavc/hevcdec: move handling of byte alignment at the end of slice header
Date: Fri, 31 May 2024 19:47:39 +0200
Message-ID: <20240531174804.17572-1-anton@khirnov.net> (raw)
Do it in hls_slice_header() rather than cabac_init_decoder() - the
former is a more logical place as according the spec the byte alignment
is a part of the slice header, not slice data. Avoids a second instance
of alignment handling in vaapi_hevc.
Also, check that alignment_bit_equal_to_one is, in fact, equal to one.
---
libavcodec/hevc_cabac.c | 2 --
libavcodec/hevcdec.c | 7 +++++++
libavcodec/hevcdec.h | 1 +
libavcodec/vaapi_hevc.c | 4 +---
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/libavcodec/hevc_cabac.c b/libavcodec/hevc_cabac.c
index 2e639a7e41..3f95c9ca05 100644
--- a/libavcodec/hevc_cabac.c
+++ b/libavcodec/hevc_cabac.c
@@ -430,8 +430,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
static int cabac_init_decoder(HEVCLocalContext *lc)
{
GetBitContext *gb = &lc->gb;
- skip_bits(gb, 1);
- align_get_bits(gb);
return ff_init_cabac_decoder(&lc->cc,
gb->buffer + get_bits_count(gb) / 8,
(get_bits_left(gb) + 7) / 8);
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index ff9a418926..ad2cbd7ece 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -1005,6 +1005,13 @@ static int hls_slice_header(HEVCContext *s)
skip_bits(gb, 8); // slice_header_extension_data_byte
}
+ ret = get_bits1(gb);
+ if (!ret) {
+ av_log(s->avctx, AV_LOG_ERROR, "alignment_bit_equal_to_one=0\n");
+ return AVERROR_INVALIDDATA;
+ }
+ sh->data_offset = align_get_bits(gb) - gb->buffer;
+
// Inferred parameters
sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
if (sh->slice_qp > 51 ||
diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h
index 5aa3d40450..3824bf621b 100644
--- a/libavcodec/hevcdec.h
+++ b/libavcodec/hevcdec.h
@@ -277,6 +277,7 @@ typedef struct SliceHeader {
int16_t chroma_offset_l1[16][2];
int slice_ctb_addr_rs;
+ unsigned data_offset;
} SliceHeader;
typedef struct CodingUnit {
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 0f5dd50351..f0a0f295d9 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -485,9 +485,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
.slice_data_size = size,
.slice_data_offset = 0,
.slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
- /* Add 1 to the bits count here to account for the byte_alignment bit, which
- * always is at least one bit and not accounted for otherwise. */
- .slice_data_byte_offset = (get_bits_count(&h->HEVClc->gb) + 1 + 7) / 8,
+ .slice_data_byte_offset = sh->data_offset,
.slice_segment_address = sh->slice_segment_addr,
.slice_qp_delta = sh->slice_qp_delta,
.slice_cb_qp_offset = sh->slice_cb_qp_offset,
--
2.43.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2024-05-31 17:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-31 17:47 Anton Khirnov [this message]
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 02/11] lavc/hevcdec: drop a useless condition Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 03/11] lavc/hevcdec: include first row in SliceHeader.offset/size Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 04/11] lavc/hevcdec: drop HEVCLocalContext.gb Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 05/11] lavc/hevcdec: drop HEVCContext.HEVClc Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 06/11] lavc/hevcdec: rename HEVCContext.ref to cur_frame Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 07/11] lavc/hevcdec: rename HEVCFrame.frame to just f Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 08/11] lavc/hevcdec: drop HEVCContext.frame Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 09/11] lavc/hevc*: move to hevc/ subdir Anton Khirnov
2024-06-02 0:39 ` James Almer
2024-06-02 6:50 ` Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 10/11] lavc/hevcdec: deduplicate calling hwaccel decode_params() Anton Khirnov
2024-05-31 17:47 ` [FFmpeg-devel] [PATCH 11/11] lavc/hevcdec: drop unused HEVCContext.width/height Anton Khirnov
2024-05-31 19:11 ` Vittorio Giovara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240531174804.17572-1-anton@khirnov.net \
--to=anton@khirnov.net \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git