Mercurial > libavcodec.hg
comparison vp56.c @ 8299:524cb7f5ad2b libavcodec
avoid POSIX reserved _t suffix
author | aurel |
---|---|
date | Thu, 11 Dec 2008 22:56:19 +0000 |
parents | 800444234375 |
children | c47323828269 |
comparison
equal
deleted
inserted
replaced
8298:2dcc437528fa | 8299:524cb7f5ad2b |
---|---|
26 | 26 |
27 #include "vp56.h" | 27 #include "vp56.h" |
28 #include "vp56data.h" | 28 #include "vp56data.h" |
29 | 29 |
30 | 30 |
31 void vp56_init_dequant(vp56_context_t *s, int quantizer) | 31 void vp56_init_dequant(VP56Context *s, int quantizer) |
32 { | 32 { |
33 s->quantizer = quantizer; | 33 s->quantizer = quantizer; |
34 s->dequant_dc = vp56_dc_dequant[quantizer] << 2; | 34 s->dequant_dc = vp56_dc_dequant[quantizer] << 2; |
35 s->dequant_ac = vp56_ac_dequant[quantizer] << 2; | 35 s->dequant_ac = vp56_ac_dequant[quantizer] << 2; |
36 } | 36 } |
37 | 37 |
38 static int vp56_get_vectors_predictors(vp56_context_t *s, int row, int col, | 38 static int vp56_get_vectors_predictors(VP56Context *s, int row, int col, |
39 vp56_frame_t ref_frame) | 39 VP56Frame ref_frame) |
40 { | 40 { |
41 int nb_pred = 0; | 41 int nb_pred = 0; |
42 vp56_mv_t vect[2] = {{0,0}, {0,0}}; | 42 VP56mv vect[2] = {{0,0}, {0,0}}; |
43 int pos, offset; | 43 int pos, offset; |
44 vp56_mv_t mvp; | 44 VP56mv mvp; |
45 | 45 |
46 for (pos=0; pos<12; pos++) { | 46 for (pos=0; pos<12; pos++) { |
47 mvp.x = col + vp56_candidate_predictor_pos[pos][0]; | 47 mvp.x = col + vp56_candidate_predictor_pos[pos][0]; |
48 mvp.y = row + vp56_candidate_predictor_pos[pos][1]; | 48 mvp.y = row + vp56_candidate_predictor_pos[pos][1]; |
49 if (mvp.x < 0 || mvp.x >= s->mb_width || | 49 if (mvp.x < 0 || mvp.x >= s->mb_width || |
71 s->vector_candidate[1] = vect[1]; | 71 s->vector_candidate[1] = vect[1]; |
72 | 72 |
73 return nb_pred+1; | 73 return nb_pred+1; |
74 } | 74 } |
75 | 75 |
76 static void vp56_parse_mb_type_models(vp56_context_t *s) | 76 static void vp56_parse_mb_type_models(VP56Context *s) |
77 { | 77 { |
78 vp56_range_coder_t *c = &s->c; | 78 VP56RangeCoder *c = &s->c; |
79 vp56_model_t *model = s->modelp; | 79 Vp56Model *model = s->modelp; |
80 int i, ctx, type; | 80 int i, ctx, type; |
81 | 81 |
82 for (ctx=0; ctx<3; ctx++) { | 82 for (ctx=0; ctx<3; ctx++) { |
83 if (vp56_rac_get_prob(c, 174)) { | 83 if (vp56_rac_get_prob(c, 174)) { |
84 int idx = vp56_rac_gets(c, 4); | 84 int idx = vp56_rac_gets(c, 4); |
142 p[type] = 100 * model->mb_types_stats[ctx][type][1]; | 142 p[type] = 100 * model->mb_types_stats[ctx][type][1]; |
143 } | 143 } |
144 } | 144 } |
145 } | 145 } |
146 | 146 |
147 static vp56_mb_t vp56_parse_mb_type(vp56_context_t *s, | 147 static VP56mb vp56_parse_mb_type(VP56Context *s, |
148 vp56_mb_t prev_type, int ctx) | 148 VP56mb prev_type, int ctx) |
149 { | 149 { |
150 uint8_t *mb_type_model = s->modelp->mb_type[ctx][prev_type]; | 150 uint8_t *mb_type_model = s->modelp->mb_type[ctx][prev_type]; |
151 vp56_range_coder_t *c = &s->c; | 151 VP56RangeCoder *c = &s->c; |
152 | 152 |
153 if (vp56_rac_get_prob(c, mb_type_model[0])) | 153 if (vp56_rac_get_prob(c, mb_type_model[0])) |
154 return prev_type; | 154 return prev_type; |
155 else | 155 else |
156 return vp56_rac_get_tree(c, vp56_pmbt_tree, mb_type_model); | 156 return vp56_rac_get_tree(c, vp56_pmbt_tree, mb_type_model); |
157 } | 157 } |
158 | 158 |
159 static void vp56_decode_4mv(vp56_context_t *s, int row, int col) | 159 static void vp56_decode_4mv(VP56Context *s, int row, int col) |
160 { | 160 { |
161 vp56_mv_t mv = {0,0}; | 161 VP56mv mv = {0,0}; |
162 int type[4]; | 162 int type[4]; |
163 int b; | 163 int b; |
164 | 164 |
165 /* parse each block type */ | 165 /* parse each block type */ |
166 for (b=0; b<4; b++) { | 166 for (b=0; b<4; b++) { |
171 | 171 |
172 /* get vectors */ | 172 /* get vectors */ |
173 for (b=0; b<4; b++) { | 173 for (b=0; b<4; b++) { |
174 switch (type[b]) { | 174 switch (type[b]) { |
175 case VP56_MB_INTER_NOVEC_PF: | 175 case VP56_MB_INTER_NOVEC_PF: |
176 s->mv[b] = (vp56_mv_t) {0,0}; | 176 s->mv[b] = (VP56mv) {0,0}; |
177 break; | 177 break; |
178 case VP56_MB_INTER_DELTA_PF: | 178 case VP56_MB_INTER_DELTA_PF: |
179 s->parse_vector_adjustment(s, &s->mv[b]); | 179 s->parse_vector_adjustment(s, &s->mv[b]); |
180 break; | 180 break; |
181 case VP56_MB_INTER_V1_PF: | 181 case VP56_MB_INTER_V1_PF: |
195 /* chroma vectors are average luma vectors */ | 195 /* chroma vectors are average luma vectors */ |
196 if (s->avctx->codec->id == CODEC_ID_VP5) { | 196 if (s->avctx->codec->id == CODEC_ID_VP5) { |
197 s->mv[4].x = s->mv[5].x = RSHIFT(mv.x,2); | 197 s->mv[4].x = s->mv[5].x = RSHIFT(mv.x,2); |
198 s->mv[4].y = s->mv[5].y = RSHIFT(mv.y,2); | 198 s->mv[4].y = s->mv[5].y = RSHIFT(mv.y,2); |
199 } else { | 199 } else { |
200 s->mv[4] = s->mv[5] = (vp56_mv_t) {mv.x/4, mv.y/4}; | 200 s->mv[4] = s->mv[5] = (VP56mv) {mv.x/4, mv.y/4}; |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 static vp56_mb_t vp56_decode_mv(vp56_context_t *s, int row, int col) | 204 static VP56mb vp56_decode_mv(VP56Context *s, int row, int col) |
205 { | 205 { |
206 vp56_mv_t *mv, vect = {0,0}; | 206 VP56mv *mv, vect = {0,0}; |
207 int ctx, b; | 207 int ctx, b; |
208 | 208 |
209 ctx = vp56_get_vectors_predictors(s, row, col, VP56_FRAME_PREVIOUS); | 209 ctx = vp56_get_vectors_predictors(s, row, col, VP56_FRAME_PREVIOUS); |
210 s->mb_type = vp56_parse_mb_type(s, s->mb_type, ctx); | 210 s->mb_type = vp56_parse_mb_type(s, s->mb_type, ctx); |
211 s->macroblocks[row * s->mb_width + col].type = s->mb_type; | 211 s->macroblocks[row * s->mb_width + col].type = s->mb_type; |
256 s->mv[b] = *mv; | 256 s->mv[b] = *mv; |
257 | 257 |
258 return s->mb_type; | 258 return s->mb_type; |
259 } | 259 } |
260 | 260 |
261 static void vp56_add_predictors_dc(vp56_context_t *s, vp56_frame_t ref_frame) | 261 static void vp56_add_predictors_dc(VP56Context *s, VP56Frame ref_frame) |
262 { | 262 { |
263 int idx = s->scantable.permutated[0]; | 263 int idx = s->scantable.permutated[0]; |
264 int b; | 264 int b; |
265 | 265 |
266 for (b=0; b<6; b++) { | 266 for (b=0; b<6; b++) { |
267 vp56_ref_dc_t *ab = &s->above_blocks[s->above_block_idx[b]]; | 267 VP56RefDc *ab = &s->above_blocks[s->above_block_idx[b]]; |
268 vp56_ref_dc_t *lb = &s->left_block[vp56_b6to4[b]]; | 268 VP56RefDc *lb = &s->left_block[vp56_b6to4[b]]; |
269 int count = 0; | 269 int count = 0; |
270 int dc = 0; | 270 int dc = 0; |
271 int i; | 271 int i; |
272 | 272 |
273 if (ref_frame == lb->ref_frame) { | 273 if (ref_frame == lb->ref_frame) { |
297 lb->ref_frame = ref_frame; | 297 lb->ref_frame = ref_frame; |
298 s->block_coeff[b][idx] *= s->dequant_dc; | 298 s->block_coeff[b][idx] *= s->dequant_dc; |
299 } | 299 } |
300 } | 300 } |
301 | 301 |
302 static void vp56_edge_filter(vp56_context_t *s, uint8_t *yuv, | 302 static void vp56_edge_filter(VP56Context *s, uint8_t *yuv, |
303 int pix_inc, int line_inc, int t) | 303 int pix_inc, int line_inc, int t) |
304 { | 304 { |
305 int pix2_inc = 2 * pix_inc; | 305 int pix2_inc = 2 * pix_inc; |
306 int i, v; | 306 int i, v; |
307 | 307 |
312 yuv[0] = av_clip_uint8(yuv[0] - v); | 312 yuv[0] = av_clip_uint8(yuv[0] - v); |
313 yuv += line_inc; | 313 yuv += line_inc; |
314 } | 314 } |
315 } | 315 } |
316 | 316 |
317 static void vp56_deblock_filter(vp56_context_t *s, uint8_t *yuv, | 317 static void vp56_deblock_filter(VP56Context *s, uint8_t *yuv, |
318 int stride, int dx, int dy) | 318 int stride, int dx, int dy) |
319 { | 319 { |
320 int t = vp56_filter_threshold[s->quantizer]; | 320 int t = vp56_filter_threshold[s->quantizer]; |
321 if (dx) vp56_edge_filter(s, yuv + 10-dx , 1, stride, t); | 321 if (dx) vp56_edge_filter(s, yuv + 10-dx , 1, stride, t); |
322 if (dy) vp56_edge_filter(s, yuv + stride*(10-dy), stride, 1, t); | 322 if (dy) vp56_edge_filter(s, yuv + stride*(10-dy), stride, 1, t); |
323 } | 323 } |
324 | 324 |
325 static void vp56_mc(vp56_context_t *s, int b, int plane, uint8_t *src, | 325 static void vp56_mc(VP56Context *s, int b, int plane, uint8_t *src, |
326 int stride, int x, int y) | 326 int stride, int x, int y) |
327 { | 327 { |
328 uint8_t *dst=s->framep[VP56_FRAME_CURRENT]->data[plane]+s->block_offset[b]; | 328 uint8_t *dst=s->framep[VP56_FRAME_CURRENT]->data[plane]+s->block_offset[b]; |
329 uint8_t *src_block; | 329 uint8_t *src_block; |
330 int src_offset; | 330 int src_offset; |
390 } else { | 390 } else { |
391 s->dsp.put_pixels_tab[1][0](dst, src_block+src_offset, stride, 8); | 391 s->dsp.put_pixels_tab[1][0](dst, src_block+src_offset, stride, 8); |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 static void vp56_decode_mb(vp56_context_t *s, int row, int col, int is_alpha) | 395 static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha) |
396 { | 396 { |
397 AVFrame *frame_current, *frame_ref; | 397 AVFrame *frame_current, *frame_ref; |
398 vp56_mb_t mb_type; | 398 VP56mb mb_type; |
399 vp56_frame_t ref_frame; | 399 VP56Frame ref_frame; |
400 int b, ab, b_max, plane, off; | 400 int b, ab, b_max, plane, off; |
401 | 401 |
402 if (s->framep[VP56_FRAME_CURRENT]->key_frame) | 402 if (s->framep[VP56_FRAME_CURRENT]->key_frame) |
403 mb_type = VP56_MB_INTRA; | 403 mb_type = VP56_MB_INTRA; |
404 else | 404 else |
459 } | 459 } |
460 } | 460 } |
461 | 461 |
462 static int vp56_size_changed(AVCodecContext *avctx) | 462 static int vp56_size_changed(AVCodecContext *avctx) |
463 { | 463 { |
464 vp56_context_t *s = avctx->priv_data; | 464 VP56Context *s = avctx->priv_data; |
465 int stride = s->framep[VP56_FRAME_CURRENT]->linesize[0]; | 465 int stride = s->framep[VP56_FRAME_CURRENT]->linesize[0]; |
466 int i; | 466 int i; |
467 | 467 |
468 s->plane_width[0] = s->plane_width[3] = avctx->coded_width; | 468 s->plane_width[0] = s->plane_width[3] = avctx->coded_width; |
469 s->plane_width[1] = s->plane_width[2] = avctx->coded_width/2; | 469 s->plane_width[1] = s->plane_width[2] = avctx->coded_width/2; |
495 } | 495 } |
496 | 496 |
497 int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, | 497 int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, |
498 const uint8_t *buf, int buf_size) | 498 const uint8_t *buf, int buf_size) |
499 { | 499 { |
500 vp56_context_t *s = avctx->priv_data; | 500 VP56Context *s = avctx->priv_data; |
501 AVFrame *const p = s->framep[VP56_FRAME_CURRENT]; | 501 AVFrame *const p = s->framep[VP56_FRAME_CURRENT]; |
502 int remaining_buf_size = buf_size; | 502 int remaining_buf_size = buf_size; |
503 int is_alpha, alpha_offset; | 503 int is_alpha, alpha_offset; |
504 | 504 |
505 if (s->has_alpha) { | 505 if (s->has_alpha) { |
644 return buf_size; | 644 return buf_size; |
645 } | 645 } |
646 | 646 |
647 av_cold void vp56_init(AVCodecContext *avctx, int flip, int has_alpha) | 647 av_cold void vp56_init(AVCodecContext *avctx, int flip, int has_alpha) |
648 { | 648 { |
649 vp56_context_t *s = avctx->priv_data; | 649 VP56Context *s = avctx->priv_data; |
650 int i; | 650 int i; |
651 | 651 |
652 s->avctx = avctx; | 652 s->avctx = avctx; |
653 avctx->pix_fmt = has_alpha ? PIX_FMT_YUVA420P : PIX_FMT_YUV420P; | 653 avctx->pix_fmt = has_alpha ? PIX_FMT_YUVA420P : PIX_FMT_YUV420P; |
654 | 654 |
684 } | 684 } |
685 } | 685 } |
686 | 686 |
687 av_cold int vp56_free(AVCodecContext *avctx) | 687 av_cold int vp56_free(AVCodecContext *avctx) |
688 { | 688 { |
689 vp56_context_t *s = avctx->priv_data; | 689 VP56Context *s = avctx->priv_data; |
690 | 690 |
691 av_free(s->above_blocks); | 691 av_free(s->above_blocks); |
692 av_free(s->macroblocks); | 692 av_free(s->macroblocks); |
693 av_free(s->edge_emu_buffer_alloc); | 693 av_free(s->edge_emu_buffer_alloc); |
694 if (s->framep[VP56_FRAME_GOLDEN]->data[0]) | 694 if (s->framep[VP56_FRAME_GOLDEN]->data[0]) |