1 /*
2 * Sunplus JPEG decoder (SP5X)
3 * Copyright (c) 2003 Alex Beregszaszi
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 * @file
24 * Sunplus JPEG decoder (SP5X).
25 */
26
32
33
35 void *
data,
int *got_frame,
37 {
39 int buf_size = avpkt->
size;
41 const int qscale = 5;
43 int i = 0, j = 0;
44
46 return -1;
47
49 if (!recoded)
50 return -1;
51
52 /* SOI */
53 recoded[j++] = 0xFF;
54 recoded[j++] = 0xD8;
55
60
63
68
71
73 for (i = 2; i < buf_size-2 && j < buf_size+1024-2; i++)
74 recoded[j++] = buf[i];
75 else
76 for (i = 14; i < buf_size && j < buf_size+1024-3; i++)
77 {
78 recoded[j++] = buf[i];
79 if (buf[i] == 0xff)
80 recoded[j++] = 0;
81 }
82
83 /* EOI */
84 recoded[j++] = 0xFF;
85 recoded[j++] = 0xD9;
86
88 avpkt_recoded.
data = recoded;
89 avpkt_recoded.
size = j;
91
93
94 return i < 0 ? i : avpkt->
size;
95 }
96
97 #if CONFIG_SP5X_DECODER
108 .max_lowres = 3,
110 };
111 #endif
112 #if CONFIG_AMV_DECODER
122 .max_lowres = 3,
125 };
126 #endif
static const uint8_t sp5x_data_dqt[]
ptrdiff_t const GLvoid * data
int coded_width
Bitstream width / height, may be different from width/height e.g.
static av_cold int init(AVCodecContext *avctx)
static const uint8_t sp5x_data_dht[]
MJPEG encoder and decoder.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
static const uint8_t sp5x_data_sos[]
int ff_mjpeg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
av_cold int ff_mjpeg_decode_end(AVCodecContext *avctx)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
const char * name
Name of the codec implementation.
int width
picture width / height.
Libavcodec external API header.
main external API structure.
static const uint8_t sp5x_data_sof[]
av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
common internal api header.
static int sp5x_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static const uint8_t sp5x_quant_table[20][64]