mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-13 18:40:03 +01:00
lavc/hevcdec: move handling of byte alignment at the end of slice header
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.
This commit is contained in:
@@ -430,8 +430,6 @@ static int cabac_reinit(HEVCLocalContext *lc)
|
|||||||
static int cabac_init_decoder(HEVCLocalContext *lc)
|
static int cabac_init_decoder(HEVCLocalContext *lc)
|
||||||
{
|
{
|
||||||
GetBitContext *gb = &lc->gb;
|
GetBitContext *gb = &lc->gb;
|
||||||
skip_bits(gb, 1);
|
|
||||||
align_get_bits(gb);
|
|
||||||
return ff_init_cabac_decoder(&lc->cc,
|
return ff_init_cabac_decoder(&lc->cc,
|
||||||
gb->buffer + get_bits_count(gb) / 8,
|
gb->buffer + get_bits_count(gb) / 8,
|
||||||
(get_bits_left(gb) + 7) / 8);
|
(get_bits_left(gb) + 7) / 8);
|
||||||
|
|||||||
@@ -1005,6 +1005,13 @@ static int hls_slice_header(HEVCContext *s)
|
|||||||
skip_bits(gb, 8); // slice_header_extension_data_byte
|
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
|
// Inferred parameters
|
||||||
sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
|
sh->slice_qp = 26U + s->ps.pps->pic_init_qp_minus26 + sh->slice_qp_delta;
|
||||||
if (sh->slice_qp > 51 ||
|
if (sh->slice_qp > 51 ||
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ typedef struct SliceHeader {
|
|||||||
int16_t chroma_offset_l1[16][2];
|
int16_t chroma_offset_l1[16][2];
|
||||||
|
|
||||||
int slice_ctb_addr_rs;
|
int slice_ctb_addr_rs;
|
||||||
|
unsigned data_offset;
|
||||||
} SliceHeader;
|
} SliceHeader;
|
||||||
|
|
||||||
typedef struct CodingUnit {
|
typedef struct CodingUnit {
|
||||||
|
|||||||
@@ -485,9 +485,7 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
|
|||||||
.slice_data_size = size,
|
.slice_data_size = size,
|
||||||
.slice_data_offset = 0,
|
.slice_data_offset = 0,
|
||||||
.slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
|
.slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
|
||||||
/* Add 1 to the bits count here to account for the byte_alignment bit, which
|
.slice_data_byte_offset = sh->data_offset,
|
||||||
* 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_segment_address = sh->slice_segment_addr,
|
.slice_segment_address = sh->slice_segment_addr,
|
||||||
.slice_qp_delta = sh->slice_qp_delta,
|
.slice_qp_delta = sh->slice_qp_delta,
|
||||||
.slice_cb_qp_offset = sh->slice_cb_qp_offset,
|
.slice_cb_qp_offset = sh->slice_cb_qp_offset,
|
||||||
|
|||||||
Reference in New Issue
Block a user