Revision 944721c1

View differences:

libavcodec/mjpeg.c
62 62

  
63 63
/* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
64 64
/* IMPORTANT: these are only valid for 8-bit data precision! */
65
const uint8_t bits_dc_luminance[17] =
65
const uint8_t ff_mjpeg_bits_dc_luminance[17] =
66 66
{ /* 0-base */ 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 };
67
const uint8_t val_dc_luminance[] =
67
const uint8_t ff_mjpeg_val_dc_luminance[] =
68 68
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
69 69

  
70
const uint8_t bits_dc_chrominance[17] =
70
const uint8_t ff_mjpeg_bits_dc_chrominance[17] =
71 71
{ /* 0-base */ 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 };
72
const uint8_t val_dc_chrominance[] =
72
const uint8_t ff_mjpeg_val_dc_chrominance[] =
73 73
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
74 74

  
75
const uint8_t bits_ac_luminance[17] =
75
const uint8_t ff_mjpeg_bits_ac_luminance[17] =
76 76
{ /* 0-base */ 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d };
77
const uint8_t val_ac_luminance[] =
77
const uint8_t ff_mjpeg_val_ac_luminance[] =
78 78
{ 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
79 79
  0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
80 80
  0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08,
......
98 98
  0xf9, 0xfa
99 99
};
100 100

  
101
const uint8_t bits_ac_chrominance[17] =
101
const uint8_t ff_mjpeg_bits_ac_chrominance[17] =
102 102
{ /* 0-base */ 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 };
103 103

  
104
const uint8_t val_ac_chrominance[] =
104
const uint8_t ff_mjpeg_val_ac_chrominance[] =
105 105
{ 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21,
106 106
  0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71,
107 107
  0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91,
......
126 126
};
127 127

  
128 128
/* isn't this function nicer than the one in the libjpeg ? */
129
void build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
130
                                const uint8_t *bits_table, const uint8_t *val_table)
129
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
130
                                  const uint8_t *bits_table,
131
                                  const uint8_t *val_table)
131 132
{
132 133
    int i, j, k,nb, code, sym;
133 134

  
libavcodec/mjpeg.h
204 204
        case 7: ret= (left + top)>>1; break;\
205 205
    }
206 206

  
207
extern const uint8_t bits_dc_luminance[];
208
extern const uint8_t val_dc_luminance[];
207
extern const uint8_t ff_mjpeg_bits_dc_luminance[];
208
extern const uint8_t ff_mjpeg_val_dc_luminance[];
209 209

  
210
extern const uint8_t bits_dc_chrominance[];
211
extern const uint8_t val_dc_chrominance[];
210
extern const uint8_t ff_mjpeg_bits_dc_chrominance[];
211
extern const uint8_t ff_mjpeg_val_dc_chrominance[];
212 212

  
213
extern const uint8_t bits_ac_luminance[];
214
extern const uint8_t val_ac_luminance[];
213
extern const uint8_t ff_mjpeg_bits_ac_luminance[];
214
extern const uint8_t ff_mjpeg_val_ac_luminance[];
215 215

  
216
extern const uint8_t bits_ac_chrominance[];
217
extern const uint8_t val_ac_chrominance[];
216
extern const uint8_t ff_mjpeg_bits_ac_chrominance[];
217
extern const uint8_t ff_mjpeg_val_ac_chrominance[];
218 218

  
219
void build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
220
                         const uint8_t *bits_table, const uint8_t *val_table);
219
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code,
220
                                  const uint8_t *bits_table,
221
                                  const uint8_t *val_table);
221 222

  
222 223
#endif /* MJPEG_H */
libavcodec/mjpegdec.c
51 51
    assert(nb_codes <= 256);
52 52

  
53 53
    memset(huff_size, 0, sizeof(huff_size));
54
    build_huffman_codes(huff_size, huff_code, bits_table, val_table);
54
    ff_mjpeg_build_huffman_codes(huff_size, huff_code, bits_table, val_table);
55 55

  
56 56
    if(is_ac){
57 57
        memmove(huff_size+16, huff_size, sizeof(uint8_t)*nb_codes);
......
77 77
    s->first_picture = 1;
78 78
    s->org_height = avctx->coded_height;
79 79

  
80
    build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12, 0, 0);
81
    build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12, 0, 0);
82
    build_vlc(&s->vlcs[1][0], bits_ac_luminance, val_ac_luminance, 251, 0, 1);
83
    build_vlc(&s->vlcs[1][1], bits_ac_chrominance, val_ac_chrominance, 251, 0, 1);
80
    build_vlc(&s->vlcs[0][0], ff_mjpeg_bits_dc_luminance,
81
              ff_mjpeg_val_dc_luminance, 12, 0, 0);
82
    build_vlc(&s->vlcs[0][1], ff_mjpeg_bits_dc_chrominance,
83
              ff_mjpeg_val_dc_chrominance, 12, 0, 0);
84
    build_vlc(&s->vlcs[1][0], ff_mjpeg_bits_ac_luminance,
85
              ff_mjpeg_val_ac_luminance, 251, 0, 1);
86
    build_vlc(&s->vlcs[1][1], ff_mjpeg_bits_ac_chrominance,
87
              ff_mjpeg_val_ac_chrominance, 251, 0, 1);
84 88

  
85 89
    if (avctx->flags & CODEC_FLAG_EXTERN_HUFF)
86 90
    {
libavcodec/mjpegenc.c
67 67
    s->max_qcoeff= 1023;
68 68

  
69 69
    /* build all the huffman tables */
70
    build_huffman_codes(m->huff_size_dc_luminance,
71
                        m->huff_code_dc_luminance,
72
                        bits_dc_luminance,
73
                        val_dc_luminance);
74
    build_huffman_codes(m->huff_size_dc_chrominance,
75
                        m->huff_code_dc_chrominance,
76
                        bits_dc_chrominance,
77
                        val_dc_chrominance);
78
    build_huffman_codes(m->huff_size_ac_luminance,
79
                        m->huff_code_ac_luminance,
80
                        bits_ac_luminance,
81
                        val_ac_luminance);
82
    build_huffman_codes(m->huff_size_ac_chrominance,
83
                        m->huff_code_ac_chrominance,
84
                        bits_ac_chrominance,
85
                        val_ac_chrominance);
70
    ff_mjpeg_build_huffman_codes(m->huff_size_dc_luminance,
71
                                 m->huff_code_dc_luminance,
72
                                 ff_mjpeg_bits_dc_luminance,
73
                                 ff_mjpeg_val_dc_luminance);
74
    ff_mjpeg_build_huffman_codes(m->huff_size_dc_chrominance,
75
                                 m->huff_code_dc_chrominance,
76
                                 ff_mjpeg_bits_dc_chrominance,
77
                                 ff_mjpeg_val_dc_chrominance);
78
    ff_mjpeg_build_huffman_codes(m->huff_size_ac_luminance,
79
                                 m->huff_code_ac_luminance,
80
                                 ff_mjpeg_bits_ac_luminance,
81
                                 ff_mjpeg_val_ac_luminance);
82
    ff_mjpeg_build_huffman_codes(m->huff_size_ac_chrominance,
83
                                 m->huff_code_ac_chrominance,
84
                                 ff_mjpeg_bits_ac_chrominance,
85
                                 ff_mjpeg_val_ac_chrominance);
86 86

  
87 87
    s->mjpeg_ctx = m;
88 88
    return 0;
......
149 149
    ptr = pbBufPtr(p);
150 150
    put_bits(p, 16, 0); /* patched later */
151 151
    size = 2;
152
    size += put_huffman_table(s, 0, 0, bits_dc_luminance, val_dc_luminance);
153
    size += put_huffman_table(s, 0, 1, bits_dc_chrominance, val_dc_chrominance);
154

  
155
    size += put_huffman_table(s, 1, 0, bits_ac_luminance, val_ac_luminance);
156
    size += put_huffman_table(s, 1, 1, bits_ac_chrominance, val_ac_chrominance);
152
    size += put_huffman_table(s, 0, 0, ff_mjpeg_bits_dc_luminance,
153
                              ff_mjpeg_val_dc_luminance);
154
    size += put_huffman_table(s, 0, 1, ff_mjpeg_bits_dc_chrominance,
155
                              ff_mjpeg_val_dc_chrominance);
156

  
157
    size += put_huffman_table(s, 1, 0, ff_mjpeg_bits_ac_luminance,
158
                              ff_mjpeg_val_ac_luminance);
159
    size += put_huffman_table(s, 1, 1, ff_mjpeg_bits_ac_chrominance,
160
                              ff_mjpeg_val_ac_chrominance);
157 161
    ptr[0] = size >> 8;
158 162
    ptr[1] = size;
159 163
}

Also available in: Unified diff