33 #define HNM4_CHUNK_ID_PL 19536 34 #define HNM4_CHUNK_ID_IZ 23113 35 #define HNM4_CHUNK_ID_IU 21833 36 #define HNM4_CHUNK_ID_SD 17491 55 *bitbuf = bytestream2_get_le32(gb);
71 uint32_t bitbuf = 0, writeoffset = 0, count = 0;
79 if (
getbit(&gb, &bitbuf, &bits)) {
82 "Attempting to write out of bounds");
85 hnm->
current[writeoffset++] = bytestream2_get_byte(&gb);
87 if (
getbit(&gb, &bitbuf, &bits)) {
88 word = bytestream2_get_le16(&gb);
90 offset = (word >> 3) - 0x2000;
92 count = bytestream2_get_byte(&gb);
96 count =
getbit(&gb, &bitbuf, &bits) * 2;
97 count +=
getbit(&gb, &bitbuf, &bits);
98 offset = bytestream2_get_byte(&gb) - 0x0100;
101 offset += writeoffset;
102 if (offset < 0 || offset + count >= hnm->
width * hnm->
height) {
105 }
else if (writeoffset + count >= hnm->
width * hnm->
height) {
107 "Attempting to write out of bounds");
120 uint32_t x, y, src_x, src_y;
122 for (y = 0; y < hnm->
height; y++) {
124 src_x = src_y * hnm->
width + (y % 2);
125 for (x = 0; x < hnm->
width; x++) {
139 for (y = 0; y < hnm->
height; y++) {
140 memcpy(dst, src, hnm->
width);
150 uint32_t writeoffset = 0, count, left, offset;
156 count = bytestream2_peek_byte(&gb) & 0x1F;
158 tag = bytestream2_get_byte(&gb) & 0xE0;
161 hnm->
current[writeoffset++] = bytestream2_get_byte(&gb);
162 hnm->
current[writeoffset++] = bytestream2_get_byte(&gb);
163 }
else if (tag == 1) {
164 writeoffset += bytestream2_get_byte(&gb) * 2;
165 }
else if (tag == 2) {
166 count = bytestream2_get_le16(&gb);
168 writeoffset += count;
169 }
else if (tag == 3) {
170 count = bytestream2_get_byte(&gb) * 2;
172 hnm->
current[writeoffset++] = bytestream2_peek_byte(&gb);
180 previous = bytestream2_peek_byte(&gb) & 0x20;
181 backline = bytestream2_peek_byte(&gb) & 0x40;
182 backward = bytestream2_peek_byte(&gb) & 0x80;
184 swap = bytestream2_peek_byte(&gb) & 0x01;
185 offset = bytestream2_get_le16(&gb);
186 offset = (offset >> 1) & 0x7FFF;
187 offset = writeoffset + (offset * 2) - 0x8000;
191 if (!backward && offset + count >= hnm->
width * hnm->
height) {
194 }
else if (backward && offset >= hnm->
width * hnm->
height) {
197 }
else if (writeoffset + count >= hnm->
width * hnm->
height) {
199 "Attempting to write out of bounds");
235 writeoffset -= count * 2;
237 swap = hnm->
current[writeoffset];
239 hnm->
current[writeoffset + 1] = swap;
253 uint32_t writeoffset = 0, offset;
259 count = bytestream2_peek_byte(&gb) & 0x3F;
261 tag = bytestream2_get_byte(&gb) & 0xC0;
264 writeoffset += bytestream2_get_byte(&gb);
265 }
else if (tag == 1) {
266 hnm->
current[writeoffset] = bytestream2_get_byte(&gb);
267 hnm->
current[writeoffset + hnm->
width] = bytestream2_get_byte(&gb);
269 }
else if (tag == 2) {
270 writeoffset += hnm->
width;
271 }
else if (tag == 3) {
275 delta = bytestream2_peek_byte(&gb) & 0x80;
276 previous = bytestream2_peek_byte(&gb) & 0x40;
279 offset = writeoffset;
280 offset += bytestream2_get_le16(&gb);
321 int eight_bit_colors;
323 eight_bit_colors = src[7] & 0x80 && hnm->
version == 0x4a;
329 start = bytestream2_get_byte(&gb);
330 count = bytestream2_get_byte(&gb);
331 if (start == 255 && count == 255)
337 hnm->
palette[writeoffset] = bytestream2_get_be24(&gb);
338 if (!eight_bit_colors)
339 hnm->
palette[writeoffset] <<= 2;
414 "Extradata missing, decoder requires version number\n");
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
memory handling functions
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
8 bit with PIX_FMT_RGB32 palette
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int getbit(GetByteContext *gb, uint32_t *bitbuf, int *bits)
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src, uint32_t size)
static void copy_processed_frame(AVCodecContext *avctx, AVFrame *frame)
static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src, uint32_t size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
common internal API header
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_cold int hnm_decode_end(AVCodecContext *avctx)
static av_always_inline int bytestream2_tell(GetByteContext *g)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static void close(AVCodecParserContext *s)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int palette_has_changed
Tell user application that palette has changed from previous frame.
static void hnm_flip_buffers(Hnm4VideoContext *hnm)
static av_cold int hnm_decode_init(AVCodecContext *avctx)
static void decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t size)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
static int hnm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
static av_cold int init(AVCodecParserContext *s)
static void hnm_update_palette(AVCodecContext *avctx, uint8_t *src, uint32_t size)
int key_frame
1 -> keyframe, 0-> not
static void postprocess_current_frame(AVCodecContext *avctx)
AVCodec ff_hnm4_video_decoder
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 ...