/src/ffmpeg/libavcodec/texturedsp_template.c
Line | Count | Source |
1 | | /* |
2 | | * Texture block compression and decompression |
3 | | * Copyright (C) 2015 Vittorio Giovara <vittorio.giovara@gmail.com> |
4 | | * |
5 | | * This file is part of FFmpeg. |
6 | | * |
7 | | * FFmpeg is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation; either |
10 | | * version 2.1 of the License, or (at your option) any later version. |
11 | | * |
12 | | * FFmpeg is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with FFmpeg; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | * |
21 | | */ |
22 | | |
23 | | #include "avcodec.h" |
24 | | |
25 | | static int exec_func(AVCodecContext *avctx, void *arg, |
26 | | int slice, int thread_nb) |
27 | 214k | { |
28 | 214k | const TextureDSPThreadContext *ctx = arg; |
29 | 214k | uint8_t *d = ctx->tex_data.out; |
30 | 214k | int w_block = ctx->width / TEXTURE_BLOCK_W; |
31 | 214k | int h_block = ctx->height / TEXTURE_BLOCK_H; |
32 | 214k | int x, y; |
33 | 214k | int start_slice, end_slice; |
34 | 214k | int base_blocks_per_slice = h_block / ctx->slice_count; |
35 | 214k | int remainder_blocks = h_block % ctx->slice_count; |
36 | | |
37 | | /* When the frame height (in blocks) doesn't divide evenly between the |
38 | | * number of slices, spread the remaining blocks evenly between the first |
39 | | * operations */ |
40 | 214k | start_slice = slice * base_blocks_per_slice; |
41 | | /* Add any extra blocks (one per slice) that have been added before this slice */ |
42 | 214k | start_slice += FFMIN(slice, remainder_blocks); |
43 | | |
44 | 214k | end_slice = start_slice + base_blocks_per_slice; |
45 | | /* Add an extra block if there are still remainder blocks to be accounted for */ |
46 | 214k | if (slice < remainder_blocks) |
47 | 0 | end_slice++; |
48 | | |
49 | 129M | for (y = start_slice; y < end_slice; y++) { |
50 | 129M | uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H; |
51 | 129M | int off = y * w_block; |
52 | 953M | for (x = 0; x < w_block; x++) { |
53 | 823M | ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride, |
54 | 823M | d + (off + x) * ctx->tex_ratio); |
55 | 823M | } |
56 | 129M | } |
57 | | |
58 | 214k | return 0; |
59 | 214k | } texturedspenc.c:exec_func Line | Count | Source | 27 | 16.1k | { | 28 | 16.1k | const TextureDSPThreadContext *ctx = arg; | 29 | 16.1k | uint8_t *d = ctx->tex_data.out; | 30 | 16.1k | int w_block = ctx->width / TEXTURE_BLOCK_W; | 31 | 16.1k | int h_block = ctx->height / TEXTURE_BLOCK_H; | 32 | 16.1k | int x, y; | 33 | 16.1k | int start_slice, end_slice; | 34 | 16.1k | int base_blocks_per_slice = h_block / ctx->slice_count; | 35 | 16.1k | int remainder_blocks = h_block % ctx->slice_count; | 36 | | | 37 | | /* When the frame height (in blocks) doesn't divide evenly between the | 38 | | * number of slices, spread the remaining blocks evenly between the first | 39 | | * operations */ | 40 | 16.1k | start_slice = slice * base_blocks_per_slice; | 41 | | /* Add any extra blocks (one per slice) that have been added before this slice */ | 42 | 16.1k | start_slice += FFMIN(slice, remainder_blocks); | 43 | | | 44 | 16.1k | end_slice = start_slice + base_blocks_per_slice; | 45 | | /* Add an extra block if there are still remainder blocks to be accounted for */ | 46 | 16.1k | if (slice < remainder_blocks) | 47 | 0 | end_slice++; | 48 | | | 49 | 766k | for (y = start_slice; y < end_slice; y++) { | 50 | 750k | uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H; | 51 | 750k | int off = y * w_block; | 52 | 15.6M | for (x = 0; x < w_block; x++) { | 53 | 14.9M | ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride, | 54 | 14.9M | d + (off + x) * ctx->tex_ratio); | 55 | 14.9M | } | 56 | 750k | } | 57 | | | 58 | 16.1k | return 0; | 59 | 16.1k | } |
Line | Count | Source | 27 | 197k | { | 28 | 197k | const TextureDSPThreadContext *ctx = arg; | 29 | 197k | uint8_t *d = ctx->tex_data.out; | 30 | 197k | int w_block = ctx->width / TEXTURE_BLOCK_W; | 31 | 197k | int h_block = ctx->height / TEXTURE_BLOCK_H; | 32 | 197k | int x, y; | 33 | 197k | int start_slice, end_slice; | 34 | 197k | int base_blocks_per_slice = h_block / ctx->slice_count; | 35 | 197k | int remainder_blocks = h_block % ctx->slice_count; | 36 | | | 37 | | /* When the frame height (in blocks) doesn't divide evenly between the | 38 | | * number of slices, spread the remaining blocks evenly between the first | 39 | | * operations */ | 40 | 197k | start_slice = slice * base_blocks_per_slice; | 41 | | /* Add any extra blocks (one per slice) that have been added before this slice */ | 42 | 197k | start_slice += FFMIN(slice, remainder_blocks); | 43 | | | 44 | 197k | end_slice = start_slice + base_blocks_per_slice; | 45 | | /* Add an extra block if there are still remainder blocks to be accounted for */ | 46 | 197k | if (slice < remainder_blocks) | 47 | 0 | end_slice++; | 48 | | | 49 | 129M | for (y = start_slice; y < end_slice; y++) { | 50 | 129M | uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H; | 51 | 129M | int off = y * w_block; | 52 | 937M | for (x = 0; x < w_block; x++) { | 53 | 808M | ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride, | 54 | 808M | d + (off + x) * ctx->tex_ratio); | 55 | 808M | } | 56 | 129M | } | 57 | | | 58 | 197k | return 0; | 59 | 197k | } |
|
60 | | |
61 | | int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, TextureDSPThreadContext *ctx) |
62 | 214k | { |
63 | | return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count); |
64 | 214k | } ff_texturedsp_exec_compress_threads Line | Count | Source | 62 | 16.1k | { | 63 | | return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count); | 64 | 16.1k | } |
ff_texturedsp_exec_decompress_threads Line | Count | Source | 62 | 197k | { | 63 | | return avctx->execute2(avctx, exec_func, ctx, NULL, ctx->slice_count); | 64 | 197k | } |
|