MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vaapi_mpeg2_decode_slice

Function vaapi_mpeg2_decode_slice

libavcodec/vaapi_mpeg2.c:134–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
135{
136 const MpegEncContext *s = avctx->priv_data;
137 VAAPIDecodePicture *pic = s->cur_pic.ptr->hwaccel_picture_private;
138 VASliceParameterBufferMPEG2 slice_param;
139 GetBitContext gb;
140 uint32_t quantiser_scale_code, intra_slice_flag, macroblock_offset;
141 int err;
142
143 /* Determine macroblock_offset */
144 init_get_bits(&gb, buffer, 8 * size);
145 if (get_bits_long(&gb, 32) >> 8 != 1) /* start code */
146 return AVERROR_INVALIDDATA;
147 quantiser_scale_code = get_bits(&gb, 5);
148 intra_slice_flag = get_bits1(&gb);
149 if (intra_slice_flag) {
150 skip_bits(&gb, 8);
151 if (skip_1stop_8data_bits(&gb) < 0)
152 return AVERROR_INVALIDDATA;
153 }
154 macroblock_offset = get_bits_count(&gb);
155
156 slice_param = (VASliceParameterBufferMPEG2) {
157 .slice_data_size = size,
158 .slice_data_offset = 0,
159 .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
160 .macroblock_offset = macroblock_offset,
161 .slice_horizontal_position = s->mb_x,
162 .slice_vertical_position = s->mb_y >> (s->picture_structure != PICT_FRAME),
163 .quantiser_scale_code = quantiser_scale_code,
164 .intra_slice_flag = intra_slice_flag,
165 };
166
167 err = ff_vaapi_decode_make_slice_buffer(avctx, pic,
168 &slice_param, 1, sizeof(slice_param),
169 buffer, size);
170 if (err < 0) {
171 ff_vaapi_decode_cancel(avctx, pic);
172 return err;
173 }
174
175 return 0;
176}
177
178const FFHWAccel ff_mpeg2_vaapi_hwaccel = {
179 .p.name = "mpeg2_vaapi",

Callers

nothing calls this directly

Calls 9

init_get_bitsFunction · 0.85
get_bits_longFunction · 0.85
get_bits1Function · 0.85
skip_bitsFunction · 0.85
skip_1stop_8data_bitsFunction · 0.85
get_bits_countFunction · 0.85
ff_vaapi_decode_cancelFunction · 0.85
get_bitsFunction · 0.70

Tested by

no test coverage detected