yading@10
|
1 /*
|
yading@10
|
2 * MJPEG decoder
|
yading@10
|
3 * Copyright (c) 2000, 2001 Fabrice Bellard
|
yading@10
|
4 * Copyright (c) 2003 Alex Beregszaszi
|
yading@10
|
5 * Copyright (c) 2003-2004 Michael Niedermayer
|
yading@10
|
6 *
|
yading@10
|
7 * This file is part of FFmpeg.
|
yading@10
|
8 *
|
yading@10
|
9 * FFmpeg is free software; you can redistribute it and/or
|
yading@10
|
10 * modify it under the terms of the GNU Lesser General Public
|
yading@10
|
11 * License as published by the Free Software Foundation; either
|
yading@10
|
12 * version 2.1 of the License, or (at your option) any later version.
|
yading@10
|
13 *
|
yading@10
|
14 * FFmpeg is distributed in the hope that it will be useful,
|
yading@10
|
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
yading@10
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
yading@10
|
17 * Lesser General Public License for more details.
|
yading@10
|
18 *
|
yading@10
|
19 * You should have received a copy of the GNU Lesser General Public
|
yading@10
|
20 * License along with FFmpeg; if not, write to the Free Software
|
yading@10
|
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
yading@10
|
22 */
|
yading@10
|
23
|
yading@10
|
24 /**
|
yading@10
|
25 * @file
|
yading@10
|
26 * MJPEG decoder.
|
yading@10
|
27 */
|
yading@10
|
28
|
yading@10
|
29 #ifndef AVCODEC_MJPEGDEC_H
|
yading@10
|
30 #define AVCODEC_MJPEGDEC_H
|
yading@10
|
31
|
yading@10
|
32 #include "libavutil/log.h"
|
yading@10
|
33
|
yading@10
|
34 #include "avcodec.h"
|
yading@10
|
35 #include "get_bits.h"
|
yading@10
|
36 #include "dsputil.h"
|
yading@10
|
37 #include "hpeldsp.h"
|
yading@10
|
38
|
yading@10
|
39 #define MAX_COMPONENTS 4
|
yading@10
|
40
|
yading@10
|
41 typedef struct MJpegDecodeContext {
|
yading@10
|
42 AVClass *class;
|
yading@10
|
43 AVCodecContext *avctx;
|
yading@10
|
44 GetBitContext gb;
|
yading@10
|
45
|
yading@10
|
46 int start_code; /* current start code */
|
yading@10
|
47 int buffer_size;
|
yading@10
|
48 uint8_t *buffer;
|
yading@10
|
49
|
yading@10
|
50 int16_t quant_matrixes[4][64];
|
yading@10
|
51 VLC vlcs[3][4];
|
yading@10
|
52 int qscale[4]; ///< quantizer scale calculated from quant_matrixes
|
yading@10
|
53
|
yading@10
|
54 int org_height; /* size given at codec init */
|
yading@10
|
55 int first_picture; /* true if decoding first picture */
|
yading@10
|
56 int interlaced; /* true if interlaced */
|
yading@10
|
57 int bottom_field; /* true if bottom field */
|
yading@10
|
58 int lossless;
|
yading@10
|
59 int ls;
|
yading@10
|
60 int progressive;
|
yading@10
|
61 int rgb;
|
yading@10
|
62 int upscale_h;
|
yading@10
|
63 int chroma_height;
|
yading@10
|
64 int upscale_v;
|
yading@10
|
65 int rct; /* standard rct */
|
yading@10
|
66 int pegasus_rct; /* pegasus reversible colorspace transform */
|
yading@10
|
67 int bits; /* bits per component */
|
yading@10
|
68
|
yading@10
|
69 int maxval;
|
yading@10
|
70 int near; ///< near lossless bound (si 0 for lossless)
|
yading@10
|
71 int t1,t2,t3;
|
yading@10
|
72 int reset; ///< context halfing interval ?rename
|
yading@10
|
73
|
yading@10
|
74 int width, height;
|
yading@10
|
75 int mb_width, mb_height;
|
yading@10
|
76 int nb_components;
|
yading@10
|
77 int block_stride[MAX_COMPONENTS];
|
yading@10
|
78 int component_id[MAX_COMPONENTS];
|
yading@10
|
79 int h_count[MAX_COMPONENTS]; /* horizontal and vertical count for each component */
|
yading@10
|
80 int v_count[MAX_COMPONENTS];
|
yading@10
|
81 int comp_index[MAX_COMPONENTS];
|
yading@10
|
82 int dc_index[MAX_COMPONENTS];
|
yading@10
|
83 int ac_index[MAX_COMPONENTS];
|
yading@10
|
84 int nb_blocks[MAX_COMPONENTS];
|
yading@10
|
85 int h_scount[MAX_COMPONENTS];
|
yading@10
|
86 int v_scount[MAX_COMPONENTS];
|
yading@10
|
87 int h_max, v_max; /* maximum h and v counts */
|
yading@10
|
88 int quant_index[4]; /* quant table index for each component */
|
yading@10
|
89 int last_dc[MAX_COMPONENTS]; /* last DEQUANTIZED dc (XXX: am I right to do that ?) */
|
yading@10
|
90 AVFrame picture; /* picture structure */
|
yading@10
|
91 AVFrame *picture_ptr; /* pointer to picture structure */
|
yading@10
|
92 int got_picture; ///< we found a SOF and picture is valid, too.
|
yading@10
|
93 int linesize[MAX_COMPONENTS]; ///< linesize << interlaced
|
yading@10
|
94 int8_t *qscale_table;
|
yading@10
|
95 DECLARE_ALIGNED(16, int16_t, block)[64];
|
yading@10
|
96 int16_t (*blocks[MAX_COMPONENTS])[64]; ///< intermediate sums (progressive mode)
|
yading@10
|
97 uint8_t *last_nnz[MAX_COMPONENTS];
|
yading@10
|
98 uint64_t coefs_finished[MAX_COMPONENTS]; ///< bitmask of which coefs have been completely decoded (progressive mode)
|
yading@10
|
99 ScanTable scantable;
|
yading@10
|
100 DSPContext dsp;
|
yading@10
|
101 HpelDSPContext hdsp;
|
yading@10
|
102
|
yading@10
|
103 int restart_interval;
|
yading@10
|
104 int restart_count;
|
yading@10
|
105
|
yading@10
|
106 int buggy_avid;
|
yading@10
|
107 int cs_itu601;
|
yading@10
|
108 int interlace_polarity;
|
yading@10
|
109
|
yading@10
|
110 int mjpb_skiptosod;
|
yading@10
|
111
|
yading@10
|
112 int cur_scan; /* current scan, used by JPEG-LS */
|
yading@10
|
113 int flipped; /* true if picture is flipped */
|
yading@10
|
114
|
yading@10
|
115 uint16_t (*ljpeg_buffer)[4];
|
yading@10
|
116 unsigned int ljpeg_buffer_size;
|
yading@10
|
117
|
yading@10
|
118 int extern_huff;
|
yading@10
|
119 } MJpegDecodeContext;
|
yading@10
|
120
|
yading@10
|
121 int ff_mjpeg_decode_init(AVCodecContext *avctx);
|
yading@10
|
122 int ff_mjpeg_decode_end(AVCodecContext *avctx);
|
yading@10
|
123 int ff_mjpeg_decode_frame(AVCodecContext *avctx,
|
yading@10
|
124 void *data, int *got_frame,
|
yading@10
|
125 AVPacket *avpkt);
|
yading@10
|
126 int ff_mjpeg_decode_dqt(MJpegDecodeContext *s);
|
yading@10
|
127 int ff_mjpeg_decode_dht(MJpegDecodeContext *s);
|
yading@10
|
128 int ff_mjpeg_decode_sof(MJpegDecodeContext *s);
|
yading@10
|
129 int ff_mjpeg_decode_sos(MJpegDecodeContext *s,
|
yading@10
|
130 const uint8_t *mb_bitmask, const AVFrame *reference);
|
yading@10
|
131 int ff_mjpeg_find_marker(MJpegDecodeContext *s,
|
yading@10
|
132 const uint8_t **buf_ptr, const uint8_t *buf_end,
|
yading@10
|
133 const uint8_t **unescaped_buf_ptr, int *unescaped_buf_size);
|
yading@10
|
134
|
yading@10
|
135 #endif /* AVCODEC_MJPEGDEC_H */
|