3 * Copyright (c) 2012 Konstantin Shishkov
5 * This file is part of Libav.
7 * Libav 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.
12 * Libav 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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 #include "libavutil/intreadwrite.h"
31 #include "bytestream.h"
51 static const uint8_t luma_quant[64] = {
52 8, 6, 5, 8, 12, 20, 26, 31,
53 6, 6, 7, 10, 13, 29, 30, 28,
54 7, 7, 8, 12, 20, 29, 35, 28,
55 7, 9, 11, 15, 26, 44, 40, 31,
56 9, 11, 19, 28, 34, 55, 52, 39,
57 12, 18, 28, 32, 41, 52, 57, 46,
58 25, 32, 39, 44, 52, 61, 60, 51,
59 36, 46, 48, 49, 56, 50, 52, 50
62 static const uint8_t chroma_quant[64] = {
63 9, 9, 12, 24, 50, 50, 50, 50,
64 9, 11, 13, 33, 50, 50, 50, 50,
65 12, 13, 28, 50, 50, 50, 50, 50,
66 24, 33, 50, 50, 50, 50, 50, 50,
67 50, 50, 50, 50, 50, 50, 50, 50,
68 50, 50, 50, 50, 50, 50, 50, 50,
69 50, 50, 50, 50, 50, 50, 50, 50,
70 50, 50, 50, 50, 50, 50, 50, 50,
73 typedef struct JPGContext {
77 VLC dc_vlc[2], ac_vlc[2];
79 DECLARE_ALIGNED(16, int16_t, block)[6][64];
84 typedef struct G2MContext {
89 int width, height, bpp;
90 int tile_width, tile_height;
91 int tiles_x, tiles_y, tile_x, tile_y;
96 int framebuf_stride, old_width, old_height;
98 uint8_t *synth_tile, *jpeg_tile;
99 int tile_stride, old_tile_w, old_tile_h;
101 uint8_t *kempf_buf, *kempf_flags;
106 int cursor_w, cursor_h, cursor_x, cursor_y;
107 int cursor_hot_x, cursor_hot_y;
110 static av_cold int build_vlc(VLC *vlc, const uint8_t *bits_table,
111 const uint8_t *val_table, int nb_codes,
114 uint8_t huff_size[256] = { 0 };
115 uint16_t huff_code[256];
116 uint16_t huff_sym[256];
119 ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
121 for (i = 0; i < 256; i++)
122 huff_sym[i] = i + 16 * is_ac;
125 huff_sym[0] = 16 * 256;
127 return ff_init_vlc_sparse(vlc, 9, nb_codes, huff_size, 1, 1,
128 huff_code, 2, 2, huff_sym, 2, 2, 0);
131 static av_cold int jpg_init(AVCodecContext *avctx, JPGContext *c)
135 ret = build_vlc(&c->dc_vlc[0], avpriv_mjpeg_bits_dc_luminance,
136 avpriv_mjpeg_val_dc, 12, 0);
139 ret = build_vlc(&c->dc_vlc[1], avpriv_mjpeg_bits_dc_chrominance,
140 avpriv_mjpeg_val_dc, 12, 0);
143 ret = build_vlc(&c->ac_vlc[0], avpriv_mjpeg_bits_ac_luminance,
144 avpriv_mjpeg_val_ac_luminance, 251, 1);
147 ret = build_vlc(&c->ac_vlc[1], avpriv_mjpeg_bits_ac_chrominance,
148 avpriv_mjpeg_val_ac_chrominance, 251, 1);
152 ff_dsputil_init(&c->dsp, avctx);
153 ff_init_scantable(c->dsp.idct_permutation, &c->scantable,
159 static av_cold void jpg_free_context(JPGContext *ctx)
163 for (i = 0; i < 2; i++) {
164 ff_free_vlc(&ctx->dc_vlc[i]);
165 ff_free_vlc(&ctx->ac_vlc[i]);
171 static void jpg_unescape(const uint8_t *src, int src_size,
172 uint8_t *dst, int *dst_size)
174 const uint8_t *src_end = src + src_size;
175 uint8_t *dst_start = dst;
177 while (src < src_end) {
182 if (x == 0xFF && !*src)
185 *dst_size = dst - dst_start;
188 static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
189 int plane, int16_t *block)
192 const int is_chroma = !!plane;
193 const uint8_t *qmat = is_chroma ? chroma_quant : luma_quant;
195 c->dsp.clear_block(block);
196 dc = get_vlc2(gb, c->dc_vlc[is_chroma].table, 9, 3);
198 return AVERROR_INVALIDDATA;
200 dc = get_xbits(gb, dc);
201 dc = dc * qmat[0] + c->prev_dc[plane];
203 c->prev_dc[plane] = dc;
207 val = get_vlc2(gb, c->ac_vlc[is_chroma].table, 9, 3);
209 return AVERROR_INVALIDDATA;
213 return val ? AVERROR_INVALIDDATA : 0;
217 val = get_xbits(gb, nbits);
218 val *= qmat[ff_zigzag_direct[pos]];
219 block[c->scantable.permutated[pos]] = val;
225 static inline void yuv2rgb(uint8_t *out, int Y, int U, int V)
227 out[0] = av_clip_uint8(Y + ( 91881 * V + 32768 >> 16));
228 out[1] = av_clip_uint8(Y + (-22554 * U - 46802 * V + 32768 >> 16));
229 out[2] = av_clip_uint8(Y + (116130 * U + 32768 >> 16));
232 static int jpg_decode_data(JPGContext *c, int width, int height,
233 const uint8_t *src, int src_size,
234 uint8_t *dst, int dst_stride,
235 const uint8_t *mask, int mask_stride, int num_mbs,
239 int mb_w, mb_h, mb_x, mb_y, i, j;
244 if ((ret = av_reallocp(&c->buf,
245 src_size + FF_INPUT_BUFFER_PADDING_SIZE)) < 0)
247 jpg_unescape(src, src_size, c->buf, &unesc_size);
248 memset(c->buf + unesc_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
249 init_get_bits(&gb, c->buf, unesc_size * 8);
251 width = FFALIGN(width, 16);
253 mb_h = (height + 15) >> 4;
256 num_mbs = mb_w * mb_h;
258 for (i = 0; i < 3; i++)
259 c->prev_dc[i] = 1024;
261 for (mb_y = 0; mb_y < mb_h; mb_y++) {
262 for (mb_x = 0; mb_x < mb_w; mb_x++) {
263 if (mask && !mask[mb_x]) {
267 for (j = 0; j < 2; j++) {
268 for (i = 0; i < 2; i++) {
269 if ((ret = jpg_decode_block(c, &gb, 0,
270 c->block[i + j * 2])) != 0)
272 c->dsp.idct(c->block[i + j * 2]);
275 for (i = 1; i < 3; i++) {
276 if ((ret = jpg_decode_block(c, &gb, i, c->block[i + 3])) != 0)
278 c->dsp.idct(c->block[i + 3]);
281 for (j = 0; j < 16; j++) {
282 uint8_t *out = dst + bx * 3 + (by + j) * dst_stride;
283 for (i = 0; i < 16; i++) {
286 Y = c->block[(j >> 3) * 2 + (i >> 3)][(i & 7) + (j & 7) * 8];
287 U = c->block[4 ^ swapuv][(i >> 1) + (j >> 1) * 8] - 128;
288 V = c->block[5 ^ swapuv][(i >> 1) + (j >> 1) * 8] - 128;
289 yuv2rgb(out + i * 3, Y, U, V);
306 static void kempf_restore_buf(const uint8_t *src, int len,
307 uint8_t *dst, int stride,
308 const uint8_t *jpeg_tile, int tile_stride,
309 int width, int height,
310 const uint8_t *pal, int npal, int tidx)
315 init_get_bits(&gb, src, len * 8);
317 if (npal <= 2) nb = 1;
318 else if (npal <= 4) nb = 2;
319 else if (npal <= 16) nb = 4;
322 for (j = 0; j < height; j++, dst += stride, jpeg_tile += tile_stride) {
323 if (get_bits(&gb, 8))
325 for (i = 0; i < width; i++) {
326 col = get_bits(&gb, nb);
328 memcpy(dst + i * 3, pal + col * 3, 3);
330 memcpy(dst + i * 3, jpeg_tile + i * 3, 3);
335 static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
336 const uint8_t *src, int src_size)
339 int hdr, zsize, npal, tidx = -1, ret;
341 const uint8_t *src_end = src + src_size;
342 uint8_t pal[768], transp[3];
343 uLongf dlen = (c->tile_width + 1) * c->tile_height;
345 int nblocks, cblocks, bstride;
346 int bits, bitbuf, coded;
347 uint8_t *dst = c->framebuf + tile_x * c->tile_width * 3 +
348 tile_y * c->tile_height * c->framebuf_stride;
351 return AVERROR_INVALIDDATA;
353 width = FFMIN(c->width - tile_x * c->tile_width, c->tile_width);
354 height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
360 memcpy(transp, src, 3);
362 for (j = 0; j < height; j++, dst += c->framebuf_stride)
363 for (i = 0; i < width; i++)
364 memcpy(dst + i * 3, transp, 3);
366 } else if (sub_type == 1) {
367 return jpg_decode_data(&c->jc, width, height, src, src_end - src,
368 dst, c->framebuf_stride, NULL, 0, 0, 0);
372 memcpy(transp, src, 3);
376 memcpy(pal, src, npal * 3); src += npal * 3;
378 for (i = 0; i < npal; i++) {
379 if (!memcmp(pal + i * 3, transp, 3)) {
386 if (src_end - src < 2)
388 zsize = (src[0] << 8) | src[1]; src += 2;
390 if (src_end - src < zsize)
391 return AVERROR_INVALIDDATA;
393 ret = uncompress(c->kempf_buf, &dlen, src, zsize);
395 return AVERROR_INVALIDDATA;
399 kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
400 NULL, 0, width, height, pal, npal, tidx);
404 nblocks = *src++ + 1;
406 bstride = FFALIGN(width, 16) >> 4;
407 // blocks are coded LSB and we need normal bitreader for JPEG data
409 for (i = 0; i < (FFALIGN(height, 16) >> 4); i++) {
410 for (j = 0; j < (FFALIGN(width, 16) >> 4); j++) {
419 if (cblocks > nblocks)
420 return AVERROR_INVALIDDATA;
421 c->kempf_flags[j + i * bstride] = coded;
425 memset(c->jpeg_tile, 0, c->tile_stride * height);
426 jpg_decode_data(&c->jc, width, height, src, src_end - src,
427 c->jpeg_tile, c->tile_stride,
428 c->kempf_flags, bstride, nblocks, 0);
430 kempf_restore_buf(c->kempf_buf, dlen, dst, c->framebuf_stride,
431 c->jpeg_tile, c->tile_stride,
432 width, height, pal, npal, tidx);
437 static int g2m_init_buffers(G2MContext *c)
441 if (!c->framebuf || c->old_width < c->width || c->old_height < c->height) {
442 c->framebuf_stride = FFALIGN(c->width * 3, 16);
443 aligned_height = FFALIGN(c->height, 16);
444 av_free(c->framebuf);
445 c->framebuf = av_mallocz(c->framebuf_stride * aligned_height);
447 return AVERROR(ENOMEM);
449 if (!c->synth_tile || !c->jpeg_tile ||
450 c->old_tile_w < c->tile_width ||
451 c->old_tile_h < c->tile_height) {
452 c->tile_stride = FFALIGN(c->tile_width * 3, 16);
453 aligned_height = FFALIGN(c->tile_height, 16);
454 av_free(c->synth_tile);
455 av_free(c->jpeg_tile);
456 av_free(c->kempf_buf);
457 av_free(c->kempf_flags);
458 c->synth_tile = av_mallocz(c->tile_stride * aligned_height);
459 c->jpeg_tile = av_mallocz(c->tile_stride * aligned_height);
460 c->kempf_buf = av_mallocz((c->tile_width + 1) * aligned_height
461 + FF_INPUT_BUFFER_PADDING_SIZE);
462 c->kempf_flags = av_mallocz( c->tile_width * aligned_height);
463 if (!c->synth_tile || !c->jpeg_tile ||
464 !c->kempf_buf || !c->kempf_flags)
465 return AVERROR(ENOMEM);
471 static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
477 uint32_t cur_size, cursor_w, cursor_h, cursor_stride;
478 uint32_t cursor_hot_x, cursor_hot_y;
481 cur_size = bytestream2_get_be32(gb);
482 cursor_w = bytestream2_get_byte(gb);
483 cursor_h = bytestream2_get_byte(gb);
484 cursor_hot_x = bytestream2_get_byte(gb);
485 cursor_hot_y = bytestream2_get_byte(gb);
486 cursor_fmt = bytestream2_get_byte(gb);
488 cursor_stride = FFALIGN(cursor_w, 32) * 4;
490 if (cursor_w < 1 || cursor_w > 256 ||
491 cursor_h < 1 || cursor_h > 256) {
492 av_log(avctx, AV_LOG_ERROR, "Invalid cursor dimensions %dx%d\n",
494 return AVERROR_INVALIDDATA;
496 if (cursor_hot_x > cursor_w || cursor_hot_y > cursor_h) {
497 av_log(avctx, AV_LOG_WARNING, "Invalid hotspot position %d,%d\n",
498 cursor_hot_x, cursor_hot_y);
499 cursor_hot_x = FFMIN(cursor_hot_x, cursor_w - 1);
500 cursor_hot_y = FFMIN(cursor_hot_y, cursor_h - 1);
502 if (cur_size - 9 > bytestream2_get_bytes_left(gb) ||
503 c->cursor_w * c->cursor_h / 4 > cur_size) {
504 av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d/%d\n",
505 cur_size, bytestream2_get_bytes_left(gb));
506 return AVERROR_INVALIDDATA;
508 if (cursor_fmt != 1 && cursor_fmt != 32) {
509 avpriv_report_missing_feature(avctx, "Cursor format %d",
511 return AVERROR_PATCHWELCOME;
514 if ((err = av_reallocp(&c->cursor, cursor_stride * cursor_h)) < 0) {
515 av_log(avctx, AV_LOG_ERROR, "Cannot allocate cursor buffer\n");
519 c->cursor_w = cursor_w;
520 c->cursor_h = cursor_h;
521 c->cursor_hot_x = cursor_hot_x;
522 c->cursor_hot_y = cursor_hot_y;
523 c->cursor_fmt = cursor_fmt;
524 c->cursor_stride = cursor_stride;
527 switch (c->cursor_fmt) {
528 case 1: // old monochrome
529 for (j = 0; j < c->cursor_h; j++) {
530 for (i = 0; i < c->cursor_w; i += 32) {
531 bits = bytestream2_get_be32(gb);
532 for (k = 0; k < 32; k++) {
533 dst[0] = !!(bits & 0x80000000);
538 dst += c->cursor_stride - c->cursor_w * 4;
542 for (j = 0; j < c->cursor_h; j++) {
543 for (i = 0; i < c->cursor_w; i += 32) {
544 bits = bytestream2_get_be32(gb);
545 for (k = 0; k < 32; k++) {
546 int mask_bit = !!(bits & 0x80000000);
547 switch (dst[0] * 2 + mask_bit) {
549 dst[0] = 0xFF; dst[1] = 0x00;
550 dst[2] = 0x00; dst[3] = 0x00;
553 dst[0] = 0xFF; dst[1] = 0xFF;
554 dst[2] = 0xFF; dst[3] = 0xFF;
557 dst[0] = 0x00; dst[1] = 0x00;
558 dst[2] = 0x00; dst[3] = 0x00;
564 dst += c->cursor_stride - c->cursor_w * 4;
567 case 32: // full colour
568 /* skip monochrome version of the cursor and decode RGBA instead */
569 bytestream2_skip(gb, c->cursor_h * (FFALIGN(c->cursor_w, 32) >> 3));
570 for (j = 0; j < c->cursor_h; j++) {
571 for (i = 0; i < c->cursor_w; i++) {
572 int val = bytestream2_get_be32(gb);
578 dst += c->cursor_stride - c->cursor_w * 4;
582 return AVERROR_PATCHWELCOME;
587 #define APPLY_ALPHA(src, new, alpha) \
588 src = (src * (256 - alpha) + new * alpha) >> 8
590 static void g2m_paint_cursor(G2MContext *c, uint8_t *dst, int stride)
594 const uint8_t *cursor;
599 x = c->cursor_x - c->cursor_hot_x;
600 y = c->cursor_y - c->cursor_hot_y;
606 if (x + w > c->width)
608 if (y + h > c->height)
618 cursor += -y * c->cursor_stride;
625 for (j = 0; j < h; j++) {
626 for (i = 0; i < w; i++) {
627 uint8_t alpha = cursor[i * 4];
628 APPLY_ALPHA(dst[i * 3 + 0], cursor[i * 4 + 1], alpha);
629 APPLY_ALPHA(dst[i * 3 + 1], cursor[i * 4 + 2], alpha);
630 APPLY_ALPHA(dst[i * 3 + 2], cursor[i * 4 + 3], alpha);
633 cursor += c->cursor_stride;
637 static int g2m_decode_frame(AVCodecContext *avctx, void *data,
638 int *got_picture_ptr, AVPacket *avpkt)
640 const uint8_t *buf = avpkt->data;
641 int buf_size = avpkt->size;
642 G2MContext *c = avctx->priv_data;
644 GetByteContext bc, tbc;
653 av_log(avctx, AV_LOG_ERROR,
654 "Frame should have at least 12 bytes, got %d instead\n",
656 return AVERROR_INVALIDDATA;
659 bytestream2_init(&bc, buf, buf_size);
661 magic = bytestream2_get_be32(&bc);
662 if ((magic & ~0xF) != MKBETAG('G', '2', 'M', '0') ||
663 (magic & 0xF) < 2 || (magic & 0xF) > 4) {
664 av_log(avctx, AV_LOG_ERROR, "Wrong magic %08X\n", magic);
665 return AVERROR_INVALIDDATA;
668 if ((magic & 0xF) != 4) {
669 av_log(avctx, AV_LOG_ERROR, "G2M2 and G2M3 are not yet supported\n");
670 return AVERROR(ENOSYS);
673 while (bytestream2_get_bytes_left(&bc) > 5) {
674 chunk_size = bytestream2_get_le32(&bc) - 1;
675 chunk_type = bytestream2_get_byte(&bc);
676 if (chunk_size > bytestream2_get_bytes_left(&bc)) {
677 av_log(avctx, AV_LOG_ERROR, "Invalid chunk size %d type %02X\n",
678 chunk_size, chunk_type);
681 switch (chunk_type) {
684 if (chunk_size < 21) {
685 av_log(avctx, AV_LOG_ERROR, "Invalid display info size %d\n",
689 c->width = bytestream2_get_be32(&bc);
690 c->height = bytestream2_get_be32(&bc);
691 if (c->width < 16 || c->width > avctx->width ||
692 c->height < 16 || c->height > avctx->height) {
693 av_log(avctx, AV_LOG_ERROR,
694 "Invalid frame dimensions %dx%d\n",
695 c->width, c->height);
696 ret = AVERROR_INVALIDDATA;
699 if (c->width != avctx->width || c->height != avctx->height)
700 ff_set_dimensions(avctx, c->width, c->height);
701 c->compression = bytestream2_get_be32(&bc);
702 if (c->compression != 2 && c->compression != 3) {
703 av_log(avctx, AV_LOG_ERROR,
704 "Unknown compression method %d\n",
706 return AVERROR_PATCHWELCOME;
708 c->tile_width = bytestream2_get_be32(&bc);
709 c->tile_height = bytestream2_get_be32(&bc);
710 if (!c->tile_width || !c->tile_height ||
711 ((c->tile_width | c->tile_height) & 0xF)) {
712 av_log(avctx, AV_LOG_ERROR,
713 "Invalid tile dimensions %dx%d\n",
714 c->tile_width, c->tile_height);
715 ret = AVERROR_INVALIDDATA;
718 c->tiles_x = (c->width + c->tile_width - 1) / c->tile_width;
719 c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
720 c->bpp = bytestream2_get_byte(&bc);
722 bytestream2_skip(&bc, chunk_size);
723 if (g2m_init_buffers(c)) {
724 ret = AVERROR(ENOMEM);
730 if (!c->tiles_x || !c->tiles_y) {
731 av_log(avctx, AV_LOG_WARNING,
732 "No display info - skipping tile\n");
733 bytestream2_skip(&bc, bytestream2_get_bytes_left(&bc));
736 if (chunk_size < 2) {
737 av_log(avctx, AV_LOG_ERROR, "Invalid tile data size %d\n",
741 c->tile_x = bytestream2_get_byte(&bc);
742 c->tile_y = bytestream2_get_byte(&bc);
743 if (c->tile_x >= c->tiles_x || c->tile_y >= c->tiles_y) {
744 av_log(avctx, AV_LOG_ERROR,
745 "Invalid tile pos %d,%d (in %dx%d grid)\n",
746 c->tile_x, c->tile_y, c->tiles_x, c->tiles_y);
751 switch (c->compression) {
753 av_log(avctx, AV_LOG_ERROR,
754 "ePIC j-b compression is not implemented yet\n");
755 return AVERROR(ENOSYS);
756 case COMPR_KEMPF_J_B:
757 ret = kempf_decode_tile(c, c->tile_x, c->tile_y,
758 buf + bytestream2_tell(&bc),
762 if (ret && c->framebuf)
763 av_log(avctx, AV_LOG_ERROR, "Error decoding tile %d,%d\n",
764 c->tile_x, c->tile_y);
765 bytestream2_skip(&bc, chunk_size);
768 if (chunk_size < 5) {
769 av_log(avctx, AV_LOG_ERROR, "Invalid cursor pos size %d\n",
773 c->cursor_x = bytestream2_get_be16(&bc);
774 c->cursor_y = bytestream2_get_be16(&bc);
775 bytestream2_skip(&bc, chunk_size - 4);
778 if (chunk_size < 8) {
779 av_log(avctx, AV_LOG_ERROR, "Invalid cursor data size %d\n",
783 bytestream2_init(&tbc, buf + bytestream2_tell(&bc),
785 g2m_load_cursor(avctx, c, &tbc);
786 bytestream2_skip(&bc, chunk_size);
790 bytestream2_skip(&bc, chunk_size);
793 av_log(avctx, AV_LOG_WARNING, "Skipping chunk type %02X\n",
795 bytestream2_skip(&bc, chunk_size);
801 if (c->width && c->height) {
802 if ((ret = ff_get_buffer(avctx, pic, 0)) < 0) {
803 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
807 pic->key_frame = got_header;
808 pic->pict_type = got_header ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
810 for (i = 0; i < avctx->height; i++)
811 memcpy(pic->data[0] + i * pic->linesize[0],
812 c->framebuf + i * c->framebuf_stride,
814 g2m_paint_cursor(c, pic->data[0], pic->linesize[0]);
816 *got_picture_ptr = 1;
821 c->width = c->height = 0;
822 c->tiles_x = c->tiles_y = 0;
826 static av_cold int g2m_decode_init(AVCodecContext *avctx)
828 G2MContext * const c = avctx->priv_data;
831 if ((ret = jpg_init(avctx, &c->jc)) != 0) {
832 av_log(avctx, AV_LOG_ERROR, "Cannot initialise VLCs\n");
833 jpg_free_context(&c->jc);
834 return AVERROR(ENOMEM);
837 avctx->pix_fmt = AV_PIX_FMT_RGB24;
842 static av_cold int g2m_decode_end(AVCodecContext *avctx)
844 G2MContext * const c = avctx->priv_data;
846 jpg_free_context(&c->jc);
848 av_freep(&c->kempf_buf);
849 av_freep(&c->kempf_flags);
850 av_freep(&c->synth_tile);
851 av_freep(&c->jpeg_tile);
852 av_freep(&c->cursor);
853 av_freep(&c->framebuf);
858 AVCodec ff_g2m_decoder = {
860 .long_name = NULL_IF_CONFIG_SMALL("Go2Meeting"),
861 .type = AVMEDIA_TYPE_VIDEO,
862 .id = AV_CODEC_ID_G2M,
863 .priv_data_size = sizeof(G2MContext),
864 .init = g2m_decode_init,
865 .close = g2m_decode_end,
866 .decode = g2m_decode_frame,
867 .capabilities = CODEC_CAP_DR1,