FFmpeg
texturedsp_template.c
Go to the documentation of this file.
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 
24  int slice, int thread_nb)
25 {
27  uint8_t *d = ctx->tex_data.out;
28  int w_block = avctx->coded_width / TEXTURE_BLOCK_W;
29  int h_block = avctx->coded_height / TEXTURE_BLOCK_H;
30  int x, y;
31  int start_slice, end_slice;
32  int base_blocks_per_slice = h_block / ctx->slice_count;
33  int remainder_blocks = h_block % ctx->slice_count;
34 
35  /* When the frame height (in blocks) doesn't divide evenly between the
36  * number of slices, spread the remaining blocks evenly between the first
37  * operations */
38  start_slice = slice * base_blocks_per_slice;
39  /* Add any extra blocks (one per slice) that have been added before this slice */
40  start_slice += FFMIN(slice, remainder_blocks);
41 
42  end_slice = start_slice + base_blocks_per_slice;
43  /* Add an extra block if there are still remainder blocks to be accounted for */
44  if (slice < remainder_blocks)
45  end_slice++;
46 
47  for (y = start_slice; y < end_slice; y++) {
48  uint8_t *p = ctx->frame_data.out + y * ctx->stride * TEXTURE_BLOCK_H;
49  int off = y * w_block;
50  for (x = 0; x < w_block; x++) {
51  ctx->TEXTUREDSP_TEX_FUNC(p + x * ctx->raw_ratio, ctx->stride,
52  d + (off + x) * ctx->tex_ratio);
53  }
54  }
55 
56  return 0;
57 }
TEXTURE_BLOCK_H
#define TEXTURE_BLOCK_H
Definition: texturedsp.h:45
TEXTUREDSP_FUNC_NAME
int TEXTUREDSP_FUNC_NAME(AVCodecContext *avctx, void *arg, int slice, int thread_nb)
Definition: texturedsp_template.c:23
AVCodecContext::coded_height
int coded_height
Definition: avcodec.h:577
TextureDSPThreadContext
Definition: texturedsp.h:65
ctx
AVFormatContext * ctx
Definition: movenc.c:48
arg
const char * arg
Definition: jacosubdec.c:67
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
TEXTURE_BLOCK_W
#define TEXTURE_BLOCK_W
Definition: texturedsp.h:44
AVCodecContext
main external API structure.
Definition: avcodec.h:389
AVCodecContext::coded_width
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition: avcodec.h:577
d
d
Definition: ffmpeg_filter.c:153