Mercurial > libavcodec.hg
comparison vaapi_vc1.c @ 10767:1e0d87fc2818 libavcodec
VAAPI: fix WMV3 decoding of videos with an odd number of macroblocks per line.
author | gb |
---|---|
date | Mon, 04 Jan 2010 09:23:24 +0000 |
parents | 3b6b7fe1c27c |
children | 8a4984c5cacc |
comparison
equal
deleted
inserted
replaced
10766:78c2be62260a | 10767:1e0d87fc2818 |
---|---|
115 return get_VAMvModeVC1(v->mv_mode2); | 115 return get_VAMvModeVC1(v->mv_mode2); |
116 return 0; | 116 return 0; |
117 } | 117 } |
118 | 118 |
119 /** Pack FFmpeg bitplanes into a VABitPlaneBuffer element */ | 119 /** Pack FFmpeg bitplanes into a VABitPlaneBuffer element */ |
120 static inline uint8_t vc1_pack_bitplanes(const uint8_t *ff_bp[3], int x, int y, int stride) | 120 static inline void vc1_pack_bitplanes(uint8_t *bitplane, int n, const uint8_t *ff_bp[3], int x, int y, int stride) |
121 { | 121 { |
122 const int n = y * stride + x; | 122 const int bitplane_index = n / 2; |
123 const int ff_bp_index = y * stride + x; | |
123 uint8_t v = 0; | 124 uint8_t v = 0; |
124 if (ff_bp[0]) | 125 if (ff_bp[0]) |
125 v = ff_bp[0][n]; | 126 v = ff_bp[0][ff_bp_index]; |
126 if (ff_bp[1]) | 127 if (ff_bp[1]) |
127 v |= ff_bp[1][n] << 1; | 128 v |= ff_bp[1][ff_bp_index] << 1; |
128 if (ff_bp[2]) | 129 if (ff_bp[2]) |
129 v |= ff_bp[2][n] << 2; | 130 v |= ff_bp[2][ff_bp_index] << 2; |
130 return v; | 131 bitplane[bitplane_index] = (bitplane[bitplane_index] << 4) | v; |
131 } | 132 } |
132 | 133 |
133 static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) | 134 static int vaapi_vc1_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) |
134 { | 135 { |
135 VC1Context * const v = avctx->priv_data; | 136 VC1Context * const v = avctx->priv_data; |
278 ff_bp[1] = NULL; | 279 ff_bp[1] = NULL; |
279 ff_bp[2] = NULL; | 280 ff_bp[2] = NULL; |
280 break; | 281 break; |
281 } | 282 } |
282 | 283 |
283 bitplane = ff_vaapi_alloc_bitplane(vactx, s->mb_height * ((s->mb_width + 1) / 2)); | 284 bitplane = ff_vaapi_alloc_bitplane(vactx, (s->mb_width * s->mb_height + 1) / 2); |
284 if (!bitplane) | 285 if (!bitplane) |
285 return -1; | 286 return -1; |
286 | 287 |
287 n = 0; | 288 n = 0; |
288 for (y = 0; y < s->mb_height; y++) { | 289 for (y = 0; y < s->mb_height; y++) |
289 for (x = 0; x < s->mb_width; x += 2) { | 290 for (x = 0; x < s->mb_width; x++, n++) |
290 bitplane[n] = vc1_pack_bitplanes(ff_bp, x+1, y, s->mb_stride); | 291 vc1_pack_bitplanes(bitplane, n, ff_bp, x, y, s->mb_stride); |
291 bitplane[n] |= (vc1_pack_bitplanes(ff_bp, x, y, s->mb_stride) << 4); | 292 if (n & 1) /* move last nibble to the high order */ |
292 ++n; | 293 bitplane[n/2] <<= 4; |
293 } | |
294 } | |
295 } | 294 } |
296 return 0; | 295 return 0; |
297 } | 296 } |
298 | 297 |
299 static int vaapi_vc1_end_frame(AVCodecContext *avctx) | 298 static int vaapi_vc1_end_frame(AVCodecContext *avctx) |