Mercurial > libavcodec.hg
comparison vp3.c @ 2686:979a847cb943 libavcodec
various 10l fixes for the loop filter
author | michael |
---|---|
date | Mon, 16 May 2005 17:22:36 +0000 |
parents | c8386f5c4fb9 |
children | fa86fa423e92 |
comparison
equal
deleted
inserted
replaced
2685:bdd509b4b554 | 2686:979a847cb943 |
---|---|
2267 int x, y, plane; | 2267 int x, y, plane; |
2268 int width, height; | 2268 int width, height; |
2269 int fragment; | 2269 int fragment; |
2270 int stride; | 2270 int stride; |
2271 unsigned char *plane_data; | 2271 unsigned char *plane_data; |
2272 int bounding_values[256]; | 2272 |
2273 int bounding_values_array[256]; | |
2274 int *bounding_values= bounding_values_array+127; | |
2273 int filter_limit; | 2275 int filter_limit; |
2274 | 2276 |
2275 /* find the right loop limit value */ | 2277 /* find the right loop limit value */ |
2276 for (x = 63; x >= 0; x--) { | 2278 for (x = 63; x >= 0; x--) { |
2277 if (vp31_ac_scale_factor[x] >= s->quality_index) | 2279 if (vp31_ac_scale_factor[x] >= s->quality_index) |
2278 break; | 2280 break; |
2279 } | 2281 } |
2280 filter_limit = vp31_filter_limit_values[x]; | 2282 filter_limit = vp31_filter_limit_values[s->quality_index]; |
2281 | 2283 |
2282 /* set up the bounding values */ | 2284 /* set up the bounding values */ |
2283 memset(bounding_values, 0, 256 * sizeof(int)); | 2285 memset(bounding_values_array, 0, 256 * sizeof(int)); |
2284 for (x = 0; x < filter_limit; x++) { | 2286 for (x = 0; x < filter_limit; x++) { |
2285 bounding_values[-x - filter_limit] = -filter_limit + x; | 2287 bounding_values[-x - filter_limit] = -filter_limit + x; |
2286 bounding_values[-x] = -x; | 2288 bounding_values[-x] = -x; |
2287 bounding_values[x] = x; | 2289 bounding_values[x] = x; |
2288 bounding_values[x + filter_limit] = filter_limit - x; | 2290 bounding_values[x + filter_limit] = filter_limit - x; |
2319 | 2321 |
2320 /* do not perform left edge filter for left columns frags */ | 2322 /* do not perform left edge filter for left columns frags */ |
2321 if ((x > 0) && | 2323 if ((x > 0) && |
2322 (s->all_fragments[fragment].coding_method != MODE_COPY)) { | 2324 (s->all_fragments[fragment].coding_method != MODE_COPY)) { |
2323 horizontal_filter( | 2325 horizontal_filter( |
2324 plane_data + s->all_fragments[fragment].first_pixel, | 2326 plane_data + s->all_fragments[fragment].first_pixel - 7*stride, |
2325 stride, bounding_values); | 2327 stride, bounding_values); |
2326 } | 2328 } |
2327 | 2329 |
2328 /* do not perform top edge filter for top row fragments */ | 2330 /* do not perform top edge filter for top row fragments */ |
2329 if ((y > 0) && | 2331 if ((y > 0) && |
2330 (s->all_fragments[fragment].coding_method != MODE_COPY)) { | 2332 (s->all_fragments[fragment].coding_method != MODE_COPY)) { |
2331 vertical_filter( | 2333 vertical_filter( |
2332 plane_data + s->all_fragments[fragment].first_pixel, | 2334 plane_data + s->all_fragments[fragment].first_pixel + stride, |
2333 stride, bounding_values); | 2335 stride, bounding_values); |
2334 } | 2336 } |
2335 | 2337 |
2336 /* do not perform right edge filter for right column | 2338 /* do not perform right edge filter for right column |
2337 * fragments or if right fragment neighbor is also coded | 2339 * fragments or if right fragment neighbor is also coded |
2338 * in this frame (it will be filtered in next iteration) */ | 2340 * in this frame (it will be filtered in next iteration) */ |
2339 if ((x < width - 1) && | 2341 if ((x < width - 1) && |
2340 (s->all_fragments[fragment].coding_method != MODE_COPY) && | 2342 (s->all_fragments[fragment].coding_method != MODE_COPY) && |
2341 (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { | 2343 (s->all_fragments[fragment + 1].coding_method == MODE_COPY)) { |
2342 horizontal_filter( | 2344 horizontal_filter( |
2343 plane_data + s->all_fragments[fragment + 1].first_pixel, | 2345 plane_data + s->all_fragments[fragment + 1].first_pixel - 7*stride, |
2344 stride, bounding_values); | 2346 stride, bounding_values); |
2345 } | 2347 } |
2346 | 2348 |
2347 /* do not perform bottom edge filter for bottom row | 2349 /* do not perform bottom edge filter for bottom row |
2348 * fragments or if bottom fragment neighbor is also coded | 2350 * fragments or if bottom fragment neighbor is also coded |
2349 * in this frame (it will be filtered in the next row) */ | 2351 * in this frame (it will be filtered in the next row) */ |
2350 if ((y < height - 1) && | 2352 if ((y < height - 1) && |
2351 (s->all_fragments[fragment].coding_method != MODE_COPY) && | 2353 (s->all_fragments[fragment].coding_method != MODE_COPY) && |
2352 (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { | 2354 (s->all_fragments[fragment + width].coding_method == MODE_COPY)) { |
2353 vertical_filter( | 2355 vertical_filter( |
2354 plane_data + s->all_fragments[fragment + width].first_pixel, | 2356 plane_data + s->all_fragments[fragment + width].first_pixel + stride, |
2355 stride, bounding_values); | 2357 stride, bounding_values); |
2356 } | 2358 } |
2357 | 2359 |
2358 fragment++; | 2360 fragment++; |
2359 } | 2361 } |
2738 return -1; | 2740 return -1; |
2739 } | 2741 } |
2740 | 2742 |
2741 reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height); | 2743 reverse_dc_prediction(s, 0, s->fragment_width, s->fragment_height); |
2742 render_fragments(s, 0, s->width, s->height, 0); | 2744 render_fragments(s, 0, s->width, s->height, 0); |
2743 // apply_loop_filter(s); | |
2744 | 2745 |
2745 if ((avctx->flags & CODEC_FLAG_GRAY) == 0) { | 2746 if ((avctx->flags & CODEC_FLAG_GRAY) == 0) { |
2746 reverse_dc_prediction(s, s->u_fragment_start, | 2747 reverse_dc_prediction(s, s->u_fragment_start, |
2747 s->fragment_width / 2, s->fragment_height / 2); | 2748 s->fragment_width / 2, s->fragment_height / 2); |
2748 reverse_dc_prediction(s, s->v_fragment_start, | 2749 reverse_dc_prediction(s, s->v_fragment_start, |
2752 } else { | 2753 } else { |
2753 memset(s->current_frame.data[1], 0x80, s->width * s->height / 4); | 2754 memset(s->current_frame.data[1], 0x80, s->width * s->height / 4); |
2754 memset(s->current_frame.data[2], 0x80, s->width * s->height / 4); | 2755 memset(s->current_frame.data[2], 0x80, s->width * s->height / 4); |
2755 } | 2756 } |
2756 | 2757 |
2758 apply_loop_filter(s); | |
2757 #if KEYFRAMES_ONLY | 2759 #if KEYFRAMES_ONLY |
2758 } | 2760 } |
2759 #endif | 2761 #endif |
2760 | 2762 |
2761 *data_size=sizeof(AVFrame); | 2763 *data_size=sizeof(AVFrame); |