25#define BITSTREAM_READER_LE
103static const int8_t
luma_adjust[] = { -4, -3, -2, -1, 1, 2, 3, 4 };
106 { 1, 1, 0, -1, -1, -1, 0, 1 },
107 { 0, 1, 1, 1, 0, -1, -1, -1 }
111 20, 28, 36, 44, 52, 60, 68, 76,
112 84, 92, 100, 106, 112, 116, 120, 124,
113 128, 132, 136, 140, 144, 150, 156, 164,
114 172, 180, 188, 196, 204, 212, 220, 228
124 "Dimensions should be a multiple of two.\n");
131 if (!
s->old_y_avg || !
s->buf1 || !
s->buf2) {
136 s->linesize[0] = avctx->
width;
138 s->linesize[2] = avctx->
width / 2;
147 memset(
s->old_u, 0x10, avctx->
width * avctx->
height / 4);
148 memset(
s->old_v, 0x10, avctx->
width * avctx->
height / 4);
193 int buf_size = avpkt->
size;
198 uint8_t *old_y, *old_cb, *old_cr,
199 *new_y, *new_cb, *new_cr;
200 uint8_t *dstY, *dstU, *dstV;
201 unsigned old_y_stride, old_cb_stride, old_cr_stride,
202 new_y_stride, new_cb_stride, new_cr_stride;
203 unsigned total_blocks = avctx->
width * avctx->
height / 4,
204 block_index, block_x = 0;
205 unsigned y[4] = { 0 },
cb = 0x10,
cr = 0x10;
206 int skip = -1, y_avg = 0,
i, j;
207 uint8_t *ya =
s->old_y_avg;
210 if (buf_size <= 16) {
222 new_y_stride =
s->linesize[0];
223 new_cb_stride =
s->linesize[1];
224 new_cr_stride =
s->linesize[2];
228 old_y_stride =
s->linesize[0];
229 old_cb_stride =
s->linesize[1];
230 old_cr_stride =
s->linesize[2];
232 for (block_index = 0; block_index < total_blocks; block_index++) {
245 y[2] = old_y[old_y_stride];
246 y[3] = old_y[old_y_stride + 1];
252 unsigned sign_selector =
get_bits(&gb, 6);
253 unsigned difference_selector =
get_bits(&gb, 2);
255 for (
i = 0;
i < 4;
i++) {
263 unsigned adjust_index =
get_bits(&gb, 3);
266 for (
i = 0;
i < 4;
i++)
275 unsigned adjust_index =
get_bits(&gb, 3);
285 new_y[new_y_stride] = y[2];
286 new_y[new_y_stride + 1] = y[3];
297 if (block_x * 2 == avctx->
width) {
299 old_y += old_y_stride * 2 - avctx->
width;
300 old_cb += old_cb_stride - avctx->
width / 2;
301 old_cr += old_cr_stride - avctx->
width / 2;
302 new_y += new_y_stride * 2 - avctx->
width;
303 new_cb += new_cb_stride - avctx->
width / 2;
304 new_cr += new_cr_stride - avctx->
width / 2;
319 for (j = 0; j < avctx->
height; j++) {
321 dstY[
i] = new_y[
i] << 2;
323 new_y += new_y_stride;
325 for (j = 0; j < avctx->
height / 2; j++) {
326 for (
i = 0;
i < avctx->
width / 2;
i++) {
332 new_cb += new_cb_stride;
333 new_cr += new_cr_stride;
336 ff_dlog(avctx,
"Frame data: provided %d bytes, used %d bytes\n",
339 FFSWAP(uint8_t*,
s->old_y,
s->new_y);
340 FFSWAP(uint8_t*,
s->old_u,
s->new_u);
341 FFSWAP(uint8_t*,
s->old_v,
s->new_v);
349 .p.name =
"escape130",
const FFCodec ff_escape130_decoder
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define i(width, name, range_min, range_max)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
static const int8_t sign_table[64][4]
static const int8_t chroma_adjust[2][8]
static const uint8_t offset_table[]
static const uint8_t chroma_vals[]
static int decode_skip_count(GetBitContext *gb)
static int escape130_decode_frame(AVCodecContext *avctx, AVFrame *pic, int *got_frame, AVPacket *avpkt)
static av_cold int escape130_decode_init(AVCodecContext *avctx)
static const int8_t luma_adjust[]
static av_cold int escape130_decode_close(AVCodecContext *avctx)
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Macro definitions for various function/variable attributes.
#define FFSWAP(type, a, b)
Memory handling functions.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
This structure stores compressed data.
static double cr(void *priv, double x, double y)
static double cb(void *priv, double x, double y)