1 /*
2 * Vizrt Binary Image decoder
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /**
22 * @file
23 * Vizrt Binary Image decoder
24 */
25
34
39
41 {
44 return 0;
45 }
46
48 int compression, uint8_t **outbuf)
49 {
50 if (compression ==
VBN_COMPRESSION_NONE)
// outbuf is left NULL because gb->buf can be used directly
52
55 }
56
60 {
63 uint8_t *image_buf =
NULL;
64 int image_len;
67
69
73 }
74
75 if (bytestream2_get_le32u(gb) !=
VBN_MAGIC ||
80 }
81
82 width = bytestream2_get_le32u(gb);
83 height = bytestream2_get_le32u(gb);
84 components = bytestream2_get_le32u(gb);
85 format = bytestream2_get_le32u(gb);
86 pix_fmt = bytestream2_get_le32u(gb);
87 bytestream2_get_le32u(gb); // mipmaps
88 data_size = bytestream2_get_le32u(gb);
90
91 compression =
format & 0xffffff00;
93
97 }
98
102 }
103
107
111 linesize = avctx->
width * 3;
114 linesize = avctx->
width * 4;
115 } else {
118 }
121 av_log(avctx,
AV_LOG_ERROR,
"DXTx compression only supports 4 pixel aligned resolutions\n");
123 }
124
127 ctx->dec.tex_funct =
ctx->texdsp.dxt1_block;
128 ctx->dec.tex_ratio = 8;
130 } else {
131 ctx->dec.tex_funct =
ctx->texdsp.dxt5_block;
132 ctx->dec.tex_ratio = 16;
134 }
135 } else {
138 }
139
140 image_len =
decompress(avctx, gb, compression, &image_buf);
141 if (image_len < 0)
142 return image_len;
143
144 if (image_len < linesize * avctx->coded_height) {
148 }
149
153
155 uint8_t *flipped =
frame->data[0] +
frame->linesize[0] * (
frame->height - 1);
157 } else {
159 ctx->dec.tex_data.in = image_buf ? image_buf : gb->
buffer;
160 ctx->dec.raw_ratio = 16;
162 ctx->dec.stride = -
frame->linesize[0];
166 }
167
168 *got_frame = 1;
170
174 }
175
185 };