Mercurial > audlegacy-plugins
changeset 820:a53d893eb303 trunk
[svn] - remove more video codecs
author | nenolod |
---|---|
date | Mon, 12 Mar 2007 14:02:32 -0700 |
parents | 1481c3667dc9 |
children | 66caee79ecc0 |
files | ChangeLog src/ffmpeg/Makefile src/ffmpeg/libavcodec/ac3enc.c src/ffmpeg/libavcodec/dvbsub.c src/ffmpeg/libavcodec/dvbsubdec.c src/ffmpeg/libavcodec/dvdata.h src/ffmpeg/libavcodec/dvdsub.c src/ffmpeg/libavcodec/dvdsubenc.c src/ffmpeg/libavcodec/faac.c src/ffmpeg/libavcodec/flacenc.c src/ffmpeg/libavcodec/flicvideo.c src/ffmpeg/libavcodec/msrle.c src/ffmpeg/libavcodec/msvideo1.c src/ffmpeg/libavcodec/raw.c src/ffmpeg/libavcodec/utils.c src/ffmpeg/libavformat/Makefile |
diffstat | 16 files changed, 112 insertions(+), 10239 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Mar 12 13:58:35 2007 -0700 +++ b/ChangeLog Mon Mar 12 14:02:32 2007 -0700 @@ -1,3 +1,11 @@ +2007-03-12 20:58:35 +0000 William Pitcock <nenolod@sacredspiral.co.uk> + revision [1738] + - don't enforce stupid coding rules on us + + trunk/src/ffmpeg/libavutil/internal.h | 14 -------------- + 1 file changed, 14 deletions(-) + + 2007-03-12 20:49:56 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [1736] - remove some more stuff
--- a/src/ffmpeg/Makefile Mon Mar 12 13:58:35 2007 -0700 +++ b/src/ffmpeg/Makefile Mon Mar 12 14:02:32 2007 -0700 @@ -11,12 +11,10 @@ SOURCES = ffmpeg.c \ libavcodec/aasc.c \ - libavcodec/ac3enc.c \ libavcodec/adpcm.c \ libavcodec/adx.c \ libavcodec/alac.c \ libavcodec/allcodecs.c \ - libavcodec/apiexample.c \ libavcodec/audioconvert.c \ libavcodec/avs.c \ libavcodec/bitstream.c \ @@ -27,20 +25,13 @@ libavcodec/dpcm.c \ libavcodec/dsicinav.c \ libavcodec/dsputil.c \ - libavcodec/dvbsub.c \ - libavcodec/dvbsubdec.c \ - libavcodec/dvdsub.c \ - libavcodec/dvdsubenc.c \ libavcodec/eval.c \ - libavcodec/faac.c \ libavcodec/faandct.c \ libavcodec/fdctref.c \ libavcodec/fft.c \ libavcodec/ffv1.c \ libavcodec/flac.c \ - libavcodec/flacenc.c \ libavcodec/flashsv.c \ - libavcodec/flicvideo.c \ libavcodec/fraps.c \ libavcodec/g726.c \ libavcodec/golomb.c \ @@ -52,8 +43,6 @@ libavcodec/mdct.c \ libavcodec/mpegaudio.c \ libavcodec/mpegaudiodec.c \ - libavcodec/msrle.c \ - libavcodec/msvideo1.c \ libavcodec/opt.c \ libavcodec/parser.c \ libavcodec/pcm.c \ @@ -63,7 +52,6 @@ libavcodec/ra144.c \ libavcodec/ra288.c \ libavcodec/rangecoder.c \ - libavcodec/raw.c \ libavcodec/resample.c \ libavcodec/resample2.c \ libavcodec/rpza.c \
--- a/src/ffmpeg/libavcodec/ac3enc.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1557 +0,0 @@ -/* - * The simplest AC3 encoder - * Copyright (c) 2000 Fabrice Bellard. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file ac3enc.c - * The simplest AC3 encoder. - */ -//#define DEBUG -//#define DEBUG_BITALLOC -#include "avcodec.h" -#include "bitstream.h" -#include "crc.h" -#include "ac3.h" - -typedef struct AC3EncodeContext { - PutBitContext pb; - int nb_channels; - int nb_all_channels; - int lfe_channel; - int bit_rate; - unsigned int sample_rate; - unsigned int bsid; - unsigned int frame_size_min; /* minimum frame size in case rounding is necessary */ - unsigned int frame_size; /* current frame size in words */ - unsigned int bits_written; - unsigned int samples_written; - int halfratecod; - unsigned int frmsizecod; - unsigned int fscod; /* frequency */ - unsigned int acmod; - int lfe; - unsigned int bsmod; - short last_samples[AC3_MAX_CHANNELS][256]; - unsigned int chbwcod[AC3_MAX_CHANNELS]; - int nb_coefs[AC3_MAX_CHANNELS]; - - /* bitrate allocation control */ - int sgaincod, sdecaycod, fdecaycod, dbkneecod, floorcod; - AC3BitAllocParameters bit_alloc; - int csnroffst; - int fgaincod[AC3_MAX_CHANNELS]; - int fsnroffst[AC3_MAX_CHANNELS]; - /* mantissa encoding */ - int mant1_cnt, mant2_cnt, mant4_cnt; -} AC3EncodeContext; - -#include "ac3tab.h" - -#define MDCT_NBITS 9 -#define N (1 << MDCT_NBITS) - -/* new exponents are sent if their Norm 1 exceed this number */ -#define EXP_DIFF_THRESHOLD 1000 - -static void fft_init(int ln); - -static inline int16_t fix15(float a) -{ - int v; - v = (int)(a * (float)(1 << 15)); - if (v < -32767) - v = -32767; - else if (v > 32767) - v = 32767; - return v; -} - -static inline int calc_lowcomp1(int a, int b0, int b1) -{ - if ((b0 + 256) == b1) { - a = 384 ; - } else if (b0 > b1) { - a = a - 64; - if (a < 0) a=0; - } - return a; -} - -static inline int calc_lowcomp(int a, int b0, int b1, int bin) -{ - if (bin < 7) { - if ((b0 + 256) == b1) { - a = 384 ; - } else if (b0 > b1) { - a = a - 64; - if (a < 0) a=0; - } - } else if (bin < 20) { - if ((b0 + 256) == b1) { - a = 320 ; - } else if (b0 > b1) { - a= a - 64; - if (a < 0) a=0; - } - } else { - a = a - 128; - if (a < 0) a=0; - } - return a; -} - -/* AC3 bit allocation. The algorithm is the one described in the AC3 - spec. */ -void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap, - int8_t *exp, int start, int end, - int snroffset, int fgain, int is_lfe, - int deltbae,int deltnseg, - uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba) -{ - int bin,i,j,k,end1,v,v1,bndstrt,bndend,lowcomp,begin; - int fastleak,slowleak,address,tmp; - int16_t psd[256]; /* scaled exponents */ - int16_t bndpsd[50]; /* interpolated exponents */ - int16_t excite[50]; /* excitation */ - int16_t mask[50]; /* masking value */ - - /* exponent mapping to PSD */ - for(bin=start;bin<end;bin++) { - psd[bin]=(3072 - (exp[bin] << 7)); - } - - /* PSD integration */ - j=start; - k=masktab[start]; - do { - v=psd[j]; - j++; - end1=bndtab[k+1]; - if (end1 > end) end1=end; - for(i=j;i<end1;i++) { - int c,adr; - /* logadd */ - v1=psd[j]; - c=v-v1; - if (c >= 0) { - adr=c >> 1; - if (adr > 255) adr=255; - v=v + latab[adr]; - } else { - adr=(-c) >> 1; - if (adr > 255) adr=255; - v=v1 + latab[adr]; - } - j++; - } - bndpsd[k]=v; - k++; - } while (end > bndtab[k]); - - /* excitation function */ - bndstrt = masktab[start]; - bndend = masktab[end-1] + 1; - - if (bndstrt == 0) { - lowcomp = 0; - lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1]) ; - excite[0] = bndpsd[0] - fgain - lowcomp ; - lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2]) ; - excite[1] = bndpsd[1] - fgain - lowcomp ; - begin = 7 ; - for (bin = 2; bin < 7; bin++) { - if (!(is_lfe && bin == 6)) - lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1]) ; - fastleak = bndpsd[bin] - fgain ; - slowleak = bndpsd[bin] - s->sgain ; - excite[bin] = fastleak - lowcomp ; - if (!(is_lfe && bin == 6)) { - if (bndpsd[bin] <= bndpsd[bin+1]) { - begin = bin + 1 ; - break ; - } - } - } - - end1=bndend; - if (end1 > 22) end1=22; - - for (bin = begin; bin < end1; bin++) { - if (!(is_lfe && bin == 6)) - lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin) ; - - fastleak -= s->fdecay ; - v = bndpsd[bin] - fgain; - if (fastleak < v) fastleak = v; - - slowleak -= s->sdecay ; - v = bndpsd[bin] - s->sgain; - if (slowleak < v) slowleak = v; - - v=fastleak - lowcomp; - if (slowleak > v) v=slowleak; - - excite[bin] = v; - } - begin = 22; - } else { - /* coupling channel */ - begin = bndstrt; - - fastleak = (s->cplfleak << 8) + 768; - slowleak = (s->cplsleak << 8) + 768; - } - - for (bin = begin; bin < bndend; bin++) { - fastleak -= s->fdecay ; - v = bndpsd[bin] - fgain; - if (fastleak < v) fastleak = v; - slowleak -= s->sdecay ; - v = bndpsd[bin] - s->sgain; - if (slowleak < v) slowleak = v; - - v=fastleak; - if (slowleak > v) v = slowleak; - excite[bin] = v; - } - - /* compute masking curve */ - - for (bin = bndstrt; bin < bndend; bin++) { - v1 = excite[bin]; - tmp = s->dbknee - bndpsd[bin]; - if (tmp > 0) { - v1 += tmp >> 2; - } - v=hth[bin >> s->halfratecod][s->fscod]; - if (v1 > v) v=v1; - mask[bin] = v; - } - - /* delta bit allocation */ - - if (deltbae == 0 || deltbae == 1) { - int band, seg, delta; - band = 0 ; - for (seg = 0; seg < deltnseg; seg++) { - band += deltoffst[seg] ; - if (deltba[seg] >= 4) { - delta = (deltba[seg] - 3) << 7; - } else { - delta = (deltba[seg] - 4) << 7; - } - for (k = 0; k < deltlen[seg]; k++) { - mask[band] += delta ; - band++ ; - } - } - } - - /* compute bit allocation */ - - i = start ; - j = masktab[start] ; - do { - v=mask[j]; - v -= snroffset ; - v -= s->floor ; - if (v < 0) v = 0; - v &= 0x1fe0 ; - v += s->floor ; - - end1=bndtab[j] + bndsz[j]; - if (end1 > end) end1=end; - - for (k = i; k < end1; k++) { - address = (psd[i] - v) >> 5 ; - if (address < 0) address=0; - else if (address > 63) address=63; - bap[i] = baptab[address]; - i++; - } - } while (end > bndtab[j++]) ; -} - -typedef struct IComplex { - short re,im; -} IComplex; - -static void fft_init(int ln) -{ - int i, j, m, n; - float alpha; - - n = 1 << ln; - - for(i=0;i<(n/2);i++) { - alpha = 2 * M_PI * (float)i / (float)n; - costab[i] = fix15(cos(alpha)); - sintab[i] = fix15(sin(alpha)); - } - - for(i=0;i<n;i++) { - m=0; - for(j=0;j<ln;j++) { - m |= ((i >> j) & 1) << (ln-j-1); - } - fft_rev[i]=m; - } -} - -/* butter fly op */ -#define BF(pre, pim, qre, qim, pre1, pim1, qre1, qim1) \ -{\ - int ax, ay, bx, by;\ - bx=pre1;\ - by=pim1;\ - ax=qre1;\ - ay=qim1;\ - pre = (bx + ax) >> 1;\ - pim = (by + ay) >> 1;\ - qre = (bx - ax) >> 1;\ - qim = (by - ay) >> 1;\ -} - -#define MUL16(a,b) ((a) * (b)) - -#define CMUL(pre, pim, are, aim, bre, bim) \ -{\ - pre = (MUL16(are, bre) - MUL16(aim, bim)) >> 15;\ - pim = (MUL16(are, bim) + MUL16(bre, aim)) >> 15;\ -} - - -/* do a 2^n point complex fft on 2^ln points. */ -static void fft(IComplex *z, int ln) -{ - int j, l, np, np2; - int nblocks, nloops; - register IComplex *p,*q; - int tmp_re, tmp_im; - - np = 1 << ln; - - /* reverse */ - for(j=0;j<np;j++) { - int k; - IComplex tmp; - k = fft_rev[j]; - if (k < j) { - tmp = z[k]; - z[k] = z[j]; - z[j] = tmp; - } - } - - /* pass 0 */ - - p=&z[0]; - j=(np >> 1); - do { - BF(p[0].re, p[0].im, p[1].re, p[1].im, - p[0].re, p[0].im, p[1].re, p[1].im); - p+=2; - } while (--j != 0); - - /* pass 1 */ - - p=&z[0]; - j=np >> 2; - do { - BF(p[0].re, p[0].im, p[2].re, p[2].im, - p[0].re, p[0].im, p[2].re, p[2].im); - BF(p[1].re, p[1].im, p[3].re, p[3].im, - p[1].re, p[1].im, p[3].im, -p[3].re); - p+=4; - } while (--j != 0); - - /* pass 2 .. ln-1 */ - - nblocks = np >> 3; - nloops = 1 << 2; - np2 = np >> 1; - do { - p = z; - q = z + nloops; - for (j = 0; j < nblocks; ++j) { - - BF(p->re, p->im, q->re, q->im, - p->re, p->im, q->re, q->im); - - p++; - q++; - for(l = nblocks; l < np2; l += nblocks) { - CMUL(tmp_re, tmp_im, costab[l], -sintab[l], q->re, q->im); - BF(p->re, p->im, q->re, q->im, - p->re, p->im, tmp_re, tmp_im); - p++; - q++; - } - p += nloops; - q += nloops; - } - nblocks = nblocks >> 1; - nloops = nloops << 1; - } while (nblocks != 0); -} - -/* do a 512 point mdct */ -static void mdct512(int32_t *out, int16_t *in) -{ - int i, re, im, re1, im1; - int16_t rot[N]; - IComplex x[N/4]; - - /* shift to simplify computations */ - for(i=0;i<N/4;i++) - rot[i] = -in[i + 3*N/4]; - for(i=N/4;i<N;i++) - rot[i] = in[i - N/4]; - - /* pre rotation */ - for(i=0;i<N/4;i++) { - re = ((int)rot[2*i] - (int)rot[N-1-2*i]) >> 1; - im = -((int)rot[N/2+2*i] - (int)rot[N/2-1-2*i]) >> 1; - CMUL(x[i].re, x[i].im, re, im, -xcos1[i], xsin1[i]); - } - - fft(x, MDCT_NBITS - 2); - - /* post rotation */ - for(i=0;i<N/4;i++) { - re = x[i].re; - im = x[i].im; - CMUL(re1, im1, re, im, xsin1[i], xcos1[i]); - out[2*i] = im1; - out[N/2-1-2*i] = re1; - } -} - -/* XXX: use another norm ? */ -static int calc_exp_diff(uint8_t *exp1, uint8_t *exp2, int n) -{ - int sum, i; - sum = 0; - for(i=0;i<n;i++) { - sum += abs(exp1[i] - exp2[i]); - } - return sum; -} - -static void compute_exp_strategy(uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS], - uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], - int ch, int is_lfe) -{ - int i, j; - int exp_diff; - - /* estimate if the exponent variation & decide if they should be - reused in the next frame */ - exp_strategy[0][ch] = EXP_NEW; - for(i=1;i<NB_BLOCKS;i++) { - exp_diff = calc_exp_diff(exp[i][ch], exp[i-1][ch], N/2); -#ifdef DEBUG - av_log(NULL, AV_LOG_DEBUG, "exp_diff=%d\n", exp_diff); -#endif - if (exp_diff > EXP_DIFF_THRESHOLD) - exp_strategy[i][ch] = EXP_NEW; - else - exp_strategy[i][ch] = EXP_REUSE; - } - if (is_lfe) - return; - - /* now select the encoding strategy type : if exponents are often - recoded, we use a coarse encoding */ - i = 0; - while (i < NB_BLOCKS) { - j = i + 1; - while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE) - j++; - switch(j - i) { - case 1: - exp_strategy[i][ch] = EXP_D45; - break; - case 2: - case 3: - exp_strategy[i][ch] = EXP_D25; - break; - default: - exp_strategy[i][ch] = EXP_D15; - break; - } - i = j; - } -} - -/* set exp[i] to min(exp[i], exp1[i]) */ -static void exponent_min(uint8_t exp[N/2], uint8_t exp1[N/2], int n) -{ - int i; - - for(i=0;i<n;i++) { - if (exp1[i] < exp[i]) - exp[i] = exp1[i]; - } -} - -/* update the exponents so that they are the ones the decoder will - decode. Return the number of bits used to code the exponents */ -static int encode_exp(uint8_t encoded_exp[N/2], - uint8_t exp[N/2], - int nb_exps, - int exp_strategy) -{ - int group_size, nb_groups, i, j, k, exp_min; - uint8_t exp1[N/2]; - - switch(exp_strategy) { - case EXP_D15: - group_size = 1; - break; - case EXP_D25: - group_size = 2; - break; - default: - case EXP_D45: - group_size = 4; - break; - } - nb_groups = ((nb_exps + (group_size * 3) - 4) / (3 * group_size)) * 3; - - /* for each group, compute the minimum exponent */ - exp1[0] = exp[0]; /* DC exponent is handled separately */ - k = 1; - for(i=1;i<=nb_groups;i++) { - exp_min = exp[k]; - assert(exp_min >= 0 && exp_min <= 24); - for(j=1;j<group_size;j++) { - if (exp[k+j] < exp_min) - exp_min = exp[k+j]; - } - exp1[i] = exp_min; - k += group_size; - } - - /* constraint for DC exponent */ - if (exp1[0] > 15) - exp1[0] = 15; - - /* Decrease the delta between each groups to within 2 - * so that they can be differentially encoded */ - for (i=1;i<=nb_groups;i++) - exp1[i] = FFMIN(exp1[i], exp1[i-1] + 2); - for (i=nb_groups-1;i>=0;i--) - exp1[i] = FFMIN(exp1[i], exp1[i+1] + 2); - - /* now we have the exponent values the decoder will see */ - encoded_exp[0] = exp1[0]; - k = 1; - for(i=1;i<=nb_groups;i++) { - for(j=0;j<group_size;j++) { - encoded_exp[k+j] = exp1[i]; - } - k += group_size; - } - -#if defined(DEBUG) - av_log(NULL, AV_LOG_DEBUG, "exponents: strategy=%d\n", exp_strategy); - for(i=0;i<=nb_groups * group_size;i++) { - av_log(NULL, AV_LOG_DEBUG, "%d ", encoded_exp[i]); - } - av_log(NULL, AV_LOG_DEBUG, "\n"); -#endif - - return 4 + (nb_groups / 3) * 7; -} - -/* return the size in bits taken by the mantissa */ -static int compute_mantissa_size(AC3EncodeContext *s, uint8_t *m, int nb_coefs) -{ - int bits, mant, i; - - bits = 0; - for(i=0;i<nb_coefs;i++) { - mant = m[i]; - switch(mant) { - case 0: - /* nothing */ - break; - case 1: - /* 3 mantissa in 5 bits */ - if (s->mant1_cnt == 0) - bits += 5; - if (++s->mant1_cnt == 3) - s->mant1_cnt = 0; - break; - case 2: - /* 3 mantissa in 7 bits */ - if (s->mant2_cnt == 0) - bits += 7; - if (++s->mant2_cnt == 3) - s->mant2_cnt = 0; - break; - case 3: - bits += 3; - break; - case 4: - /* 2 mantissa in 7 bits */ - if (s->mant4_cnt == 0) - bits += 7; - if (++s->mant4_cnt == 2) - s->mant4_cnt = 0; - break; - case 14: - bits += 14; - break; - case 15: - bits += 16; - break; - default: - bits += mant - 1; - break; - } - } - return bits; -} - - -static int bit_alloc(AC3EncodeContext *s, - uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], - uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], - uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS], - int frame_bits, int csnroffst, int fsnroffst) -{ - int i, ch; - - /* compute size */ - for(i=0;i<NB_BLOCKS;i++) { - s->mant1_cnt = 0; - s->mant2_cnt = 0; - s->mant4_cnt = 0; - for(ch=0;ch<s->nb_all_channels;ch++) { - ac3_parametric_bit_allocation(&s->bit_alloc, - bap[i][ch], (int8_t *)encoded_exp[i][ch], - 0, s->nb_coefs[ch], - (((csnroffst-15) << 4) + - fsnroffst) << 2, - fgaintab[s->fgaincod[ch]], - ch == s->lfe_channel, - 2, 0, NULL, NULL, NULL); - frame_bits += compute_mantissa_size(s, bap[i][ch], - s->nb_coefs[ch]); - } - } -#if 0 - printf("csnr=%d fsnr=%d frame_bits=%d diff=%d\n", - csnroffst, fsnroffst, frame_bits, - 16 * s->frame_size - ((frame_bits + 7) & ~7)); -#endif - return 16 * s->frame_size - frame_bits; -} - -#define SNR_INC1 4 - -static int compute_bit_allocation(AC3EncodeContext *s, - uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], - uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], - uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS], - int frame_bits) -{ - int i, ch; - int csnroffst, fsnroffst; - uint8_t bap1[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; - static int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; - - /* init default parameters */ - s->sdecaycod = 2; - s->fdecaycod = 1; - s->sgaincod = 1; - s->dbkneecod = 2; - s->floorcod = 4; - for(ch=0;ch<s->nb_all_channels;ch++) - s->fgaincod[ch] = 4; - - /* compute real values */ - s->bit_alloc.fscod = s->fscod; - s->bit_alloc.halfratecod = s->halfratecod; - s->bit_alloc.sdecay = sdecaytab[s->sdecaycod] >> s->halfratecod; - s->bit_alloc.fdecay = fdecaytab[s->fdecaycod] >> s->halfratecod; - s->bit_alloc.sgain = sgaintab[s->sgaincod]; - s->bit_alloc.dbknee = dbkneetab[s->dbkneecod]; - s->bit_alloc.floor = floortab[s->floorcod]; - - /* header size */ - frame_bits += 65; - // if (s->acmod == 2) - // frame_bits += 2; - frame_bits += frame_bits_inc[s->acmod]; - - /* audio blocks */ - for(i=0;i<NB_BLOCKS;i++) { - frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */ - if (s->acmod == 2) { - frame_bits++; /* rematstr */ - if(i==0) frame_bits += 4; - } - frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */ - if (s->lfe) - frame_bits++; /* lfeexpstr */ - for(ch=0;ch<s->nb_channels;ch++) { - if (exp_strategy[i][ch] != EXP_REUSE) - frame_bits += 6 + 2; /* chbwcod[6], gainrng[2] */ - } - frame_bits++; /* baie */ - frame_bits++; /* snr */ - frame_bits += 2; /* delta / skip */ - } - frame_bits++; /* cplinu for block 0 */ - /* bit alloc info */ - /* sdcycod[2], fdcycod[2], sgaincod[2], dbpbcod[2], floorcod[3] */ - /* csnroffset[6] */ - /* (fsnoffset[4] + fgaincod[4]) * c */ - frame_bits += 2*4 + 3 + 6 + s->nb_all_channels * (4 + 3); - - /* auxdatae, crcrsv */ - frame_bits += 2; - - /* CRC */ - frame_bits += 16; - - /* now the big work begins : do the bit allocation. Modify the snr - offset until we can pack everything in the requested frame size */ - - csnroffst = s->csnroffst; - while (csnroffst >= 0 && - bit_alloc(s, bap, encoded_exp, exp_strategy, frame_bits, csnroffst, 0) < 0) - csnroffst -= SNR_INC1; - if (csnroffst < 0) { - av_log(NULL, AV_LOG_ERROR, "Bit allocation failed, try increasing the bitrate, -ab 384 for example!\n"); - return -1; - } - while ((csnroffst + SNR_INC1) <= 63 && - bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, - csnroffst + SNR_INC1, 0) >= 0) { - csnroffst += SNR_INC1; - memcpy(bap, bap1, sizeof(bap1)); - } - while ((csnroffst + 1) <= 63 && - bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, csnroffst + 1, 0) >= 0) { - csnroffst++; - memcpy(bap, bap1, sizeof(bap1)); - } - - fsnroffst = 0; - while ((fsnroffst + SNR_INC1) <= 15 && - bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, - csnroffst, fsnroffst + SNR_INC1) >= 0) { - fsnroffst += SNR_INC1; - memcpy(bap, bap1, sizeof(bap1)); - } - while ((fsnroffst + 1) <= 15 && - bit_alloc(s, bap1, encoded_exp, exp_strategy, frame_bits, - csnroffst, fsnroffst + 1) >= 0) { - fsnroffst++; - memcpy(bap, bap1, sizeof(bap1)); - } - - s->csnroffst = csnroffst; - for(ch=0;ch<s->nb_all_channels;ch++) - s->fsnroffst[ch] = fsnroffst; -#if defined(DEBUG_BITALLOC) - { - int j; - - for(i=0;i<6;i++) { - for(ch=0;ch<s->nb_all_channels;ch++) { - printf("Block #%d Ch%d:\n", i, ch); - printf("bap="); - for(j=0;j<s->nb_coefs[ch];j++) { - printf("%d ",bap[i][ch][j]); - } - printf("\n"); - } - } - } -#endif - return 0; -} - -void ac3_common_init(void) -{ - int i, j, k, l, v; - /* compute bndtab and masktab from bandsz */ - k = 0; - l = 0; - for(i=0;i<50;i++) { - bndtab[i] = l; - v = bndsz[i]; - for(j=0;j<v;j++) masktab[k++]=i; - l += v; - } - bndtab[50] = l; -} - - -static int AC3_encode_init(AVCodecContext *avctx) -{ - int freq = avctx->sample_rate; - int bitrate = avctx->bit_rate; - int channels = avctx->channels; - AC3EncodeContext *s = avctx->priv_data; - int i, j, ch; - float alpha; - static const uint8_t acmod_defs[6] = { - 0x01, /* C */ - 0x02, /* L R */ - 0x03, /* L C R */ - 0x06, /* L R SL SR */ - 0x07, /* L C R SL SR */ - 0x07, /* L C R SL SR (+LFE) */ - }; - - avctx->frame_size = AC3_FRAME_SIZE; - - /* number of channels */ - if (channels < 1 || channels > 6) - return -1; - s->acmod = acmod_defs[channels - 1]; - s->lfe = (channels == 6) ? 1 : 0; - s->nb_all_channels = channels; - s->nb_channels = channels > 5 ? 5 : channels; - s->lfe_channel = s->lfe ? 5 : -1; - - /* frequency */ - for(i=0;i<3;i++) { - for(j=0;j<3;j++) - if ((ac3_freqs[j] >> i) == freq) - goto found; - } - return -1; - found: - s->sample_rate = freq; - s->halfratecod = i; - s->fscod = j; - s->bsid = 8 + s->halfratecod; - s->bsmod = 0; /* complete main audio service */ - - /* bitrate & frame size */ - bitrate /= 1000; - for(i=0;i<19;i++) { - if ((ac3_bitratetab[i] >> s->halfratecod) == bitrate) - break; - } - if (i == 19) - return -1; - s->bit_rate = bitrate; - s->frmsizecod = i << 1; - s->frame_size_min = (bitrate * 1000 * AC3_FRAME_SIZE) / (freq * 16); - s->bits_written = 0; - s->samples_written = 0; - s->frame_size = s->frame_size_min; - - /* bit allocation init */ - for(ch=0;ch<s->nb_channels;ch++) { - /* bandwidth for each channel */ - /* XXX: should compute the bandwidth according to the frame - size, so that we avoid anoying high freq artefacts */ - s->chbwcod[ch] = 50; /* sample bandwidth as mpeg audio layer 2 table 0 */ - s->nb_coefs[ch] = ((s->chbwcod[ch] + 12) * 3) + 37; - } - if (s->lfe) { - s->nb_coefs[s->lfe_channel] = 7; /* fixed */ - } - /* initial snr offset */ - s->csnroffst = 40; - - ac3_common_init(); - - /* mdct init */ - fft_init(MDCT_NBITS - 2); - for(i=0;i<N/4;i++) { - alpha = 2 * M_PI * (i + 1.0 / 8.0) / (float)N; - xcos1[i] = fix15(-cos(alpha)); - xsin1[i] = fix15(-sin(alpha)); - } - - avctx->coded_frame= avcodec_alloc_frame(); - avctx->coded_frame->key_frame= 1; - - return 0; -} - -/* output the AC3 frame header */ -static void output_frame_header(AC3EncodeContext *s, unsigned char *frame) -{ - init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); - - put_bits(&s->pb, 16, 0x0b77); /* frame header */ - put_bits(&s->pb, 16, 0); /* crc1: will be filled later */ - put_bits(&s->pb, 2, s->fscod); - put_bits(&s->pb, 6, s->frmsizecod + (s->frame_size - s->frame_size_min)); - put_bits(&s->pb, 5, s->bsid); - put_bits(&s->pb, 3, s->bsmod); - put_bits(&s->pb, 3, s->acmod); - if ((s->acmod & 0x01) && s->acmod != 0x01) - put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */ - if (s->acmod & 0x04) - put_bits(&s->pb, 2, 1); /* XXX -6 dB */ - if (s->acmod == 0x02) - put_bits(&s->pb, 2, 0); /* surround not indicated */ - put_bits(&s->pb, 1, s->lfe); /* LFE */ - put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */ - put_bits(&s->pb, 1, 0); /* no compression control word */ - put_bits(&s->pb, 1, 0); /* no lang code */ - put_bits(&s->pb, 1, 0); /* no audio production info */ - put_bits(&s->pb, 1, 0); /* no copyright */ - put_bits(&s->pb, 1, 1); /* original bitstream */ - put_bits(&s->pb, 1, 0); /* no time code 1 */ - put_bits(&s->pb, 1, 0); /* no time code 2 */ - put_bits(&s->pb, 1, 0); /* no addtional bit stream info */ -} - -/* symetric quantization on 'levels' levels */ -static inline int sym_quant(int c, int e, int levels) -{ - int v; - - if (c >= 0) { - v = (levels * (c << e)) >> 24; - v = (v + 1) >> 1; - v = (levels >> 1) + v; - } else { - v = (levels * ((-c) << e)) >> 24; - v = (v + 1) >> 1; - v = (levels >> 1) - v; - } - assert (v >= 0 && v < levels); - return v; -} - -/* asymetric quantization on 2^qbits levels */ -static inline int asym_quant(int c, int e, int qbits) -{ - int lshift, m, v; - - lshift = e + qbits - 24; - if (lshift >= 0) - v = c << lshift; - else - v = c >> (-lshift); - /* rounding */ - v = (v + 1) >> 1; - m = (1 << (qbits-1)); - if (v >= m) - v = m - 1; - assert(v >= -m); - return v & ((1 << qbits)-1); -} - -/* Output one audio block. There are NB_BLOCKS audio blocks in one AC3 - frame */ -static void output_audio_block(AC3EncodeContext *s, - uint8_t exp_strategy[AC3_MAX_CHANNELS], - uint8_t encoded_exp[AC3_MAX_CHANNELS][N/2], - uint8_t bap[AC3_MAX_CHANNELS][N/2], - int32_t mdct_coefs[AC3_MAX_CHANNELS][N/2], - int8_t global_exp[AC3_MAX_CHANNELS], - int block_num) -{ - int ch, nb_groups, group_size, i, baie, rbnd; - uint8_t *p; - uint16_t qmant[AC3_MAX_CHANNELS][N/2]; - int exp0, exp1; - int mant1_cnt, mant2_cnt, mant4_cnt; - uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; - int delta0, delta1, delta2; - - for(ch=0;ch<s->nb_channels;ch++) - put_bits(&s->pb, 1, 0); /* 512 point MDCT */ - for(ch=0;ch<s->nb_channels;ch++) - put_bits(&s->pb, 1, 1); /* no dither */ - put_bits(&s->pb, 1, 0); /* no dynamic range */ - if (block_num == 0) { - /* for block 0, even if no coupling, we must say it. This is a - waste of bit :-) */ - put_bits(&s->pb, 1, 1); /* coupling strategy present */ - put_bits(&s->pb, 1, 0); /* no coupling strategy */ - } else { - put_bits(&s->pb, 1, 0); /* no new coupling strategy */ - } - - if (s->acmod == 2) - { - if(block_num==0) - { - /* first block must define rematrixing (rematstr) */ - put_bits(&s->pb, 1, 1); - - /* dummy rematrixing rematflg(1:4)=0 */ - for (rbnd=0;rbnd<4;rbnd++) - put_bits(&s->pb, 1, 0); - } - else - { - /* no matrixing (but should be used in the future) */ - put_bits(&s->pb, 1, 0); - } - } - -#if defined(DEBUG) - { - static int count = 0; - av_log(NULL, AV_LOG_DEBUG, "Block #%d (%d)\n", block_num, count++); - } -#endif - /* exponent strategy */ - for(ch=0;ch<s->nb_channels;ch++) { - put_bits(&s->pb, 2, exp_strategy[ch]); - } - - if (s->lfe) { - put_bits(&s->pb, 1, exp_strategy[s->lfe_channel]); - } - - for(ch=0;ch<s->nb_channels;ch++) { - if (exp_strategy[ch] != EXP_REUSE) - put_bits(&s->pb, 6, s->chbwcod[ch]); - } - - /* exponents */ - for (ch = 0; ch < s->nb_all_channels; ch++) { - switch(exp_strategy[ch]) { - case EXP_REUSE: - continue; - case EXP_D15: - group_size = 1; - break; - case EXP_D25: - group_size = 2; - break; - default: - case EXP_D45: - group_size = 4; - break; - } - nb_groups = (s->nb_coefs[ch] + (group_size * 3) - 4) / (3 * group_size); - p = encoded_exp[ch]; - - /* first exponent */ - exp1 = *p++; - put_bits(&s->pb, 4, exp1); - - /* next ones are delta encoded */ - for(i=0;i<nb_groups;i++) { - /* merge three delta in one code */ - exp0 = exp1; - exp1 = p[0]; - p += group_size; - delta0 = exp1 - exp0 + 2; - - exp0 = exp1; - exp1 = p[0]; - p += group_size; - delta1 = exp1 - exp0 + 2; - - exp0 = exp1; - exp1 = p[0]; - p += group_size; - delta2 = exp1 - exp0 + 2; - - put_bits(&s->pb, 7, ((delta0 * 5 + delta1) * 5) + delta2); - } - - if (ch != s->lfe_channel) - put_bits(&s->pb, 2, 0); /* no gain range info */ - } - - /* bit allocation info */ - baie = (block_num == 0); - put_bits(&s->pb, 1, baie); - if (baie) { - put_bits(&s->pb, 2, s->sdecaycod); - put_bits(&s->pb, 2, s->fdecaycod); - put_bits(&s->pb, 2, s->sgaincod); - put_bits(&s->pb, 2, s->dbkneecod); - put_bits(&s->pb, 3, s->floorcod); - } - - /* snr offset */ - put_bits(&s->pb, 1, baie); /* always present with bai */ - if (baie) { - put_bits(&s->pb, 6, s->csnroffst); - for(ch=0;ch<s->nb_all_channels;ch++) { - put_bits(&s->pb, 4, s->fsnroffst[ch]); - put_bits(&s->pb, 3, s->fgaincod[ch]); - } - } - - put_bits(&s->pb, 1, 0); /* no delta bit allocation */ - put_bits(&s->pb, 1, 0); /* no data to skip */ - - /* mantissa encoding : we use two passes to handle the grouping. A - one pass method may be faster, but it would necessitate to - modify the output stream. */ - - /* first pass: quantize */ - mant1_cnt = mant2_cnt = mant4_cnt = 0; - qmant1_ptr = qmant2_ptr = qmant4_ptr = NULL; - - for (ch = 0; ch < s->nb_all_channels; ch++) { - int b, c, e, v; - - for(i=0;i<s->nb_coefs[ch];i++) { - c = mdct_coefs[ch][i]; - e = encoded_exp[ch][i] - global_exp[ch]; - b = bap[ch][i]; - switch(b) { - case 0: - v = 0; - break; - case 1: - v = sym_quant(c, e, 3); - switch(mant1_cnt) { - case 0: - qmant1_ptr = &qmant[ch][i]; - v = 9 * v; - mant1_cnt = 1; - break; - case 1: - *qmant1_ptr += 3 * v; - mant1_cnt = 2; - v = 128; - break; - default: - *qmant1_ptr += v; - mant1_cnt = 0; - v = 128; - break; - } - break; - case 2: - v = sym_quant(c, e, 5); - switch(mant2_cnt) { - case 0: - qmant2_ptr = &qmant[ch][i]; - v = 25 * v; - mant2_cnt = 1; - break; - case 1: - *qmant2_ptr += 5 * v; - mant2_cnt = 2; - v = 128; - break; - default: - *qmant2_ptr += v; - mant2_cnt = 0; - v = 128; - break; - } - break; - case 3: - v = sym_quant(c, e, 7); - break; - case 4: - v = sym_quant(c, e, 11); - switch(mant4_cnt) { - case 0: - qmant4_ptr = &qmant[ch][i]; - v = 11 * v; - mant4_cnt = 1; - break; - default: - *qmant4_ptr += v; - mant4_cnt = 0; - v = 128; - break; - } - break; - case 5: - v = sym_quant(c, e, 15); - break; - case 14: - v = asym_quant(c, e, 14); - break; - case 15: - v = asym_quant(c, e, 16); - break; - default: - v = asym_quant(c, e, b - 1); - break; - } - qmant[ch][i] = v; - } - } - - /* second pass : output the values */ - for (ch = 0; ch < s->nb_all_channels; ch++) { - int b, q; - - for(i=0;i<s->nb_coefs[ch];i++) { - q = qmant[ch][i]; - b = bap[ch][i]; - switch(b) { - case 0: - break; - case 1: - if (q != 128) - put_bits(&s->pb, 5, q); - break; - case 2: - if (q != 128) - put_bits(&s->pb, 7, q); - break; - case 3: - put_bits(&s->pb, 3, q); - break; - case 4: - if (q != 128) - put_bits(&s->pb, 7, q); - break; - case 14: - put_bits(&s->pb, 14, q); - break; - case 15: - put_bits(&s->pb, 16, q); - break; - default: - put_bits(&s->pb, b - 1, q); - break; - } - } - } -} - -#define CRC16_POLY ((1 << 0) | (1 << 2) | (1 << 15) | (1 << 16)) - -static unsigned int mul_poly(unsigned int a, unsigned int b, unsigned int poly) -{ - unsigned int c; - - c = 0; - while (a) { - if (a & 1) - c ^= b; - a = a >> 1; - b = b << 1; - if (b & (1 << 16)) - b ^= poly; - } - return c; -} - -static unsigned int pow_poly(unsigned int a, unsigned int n, unsigned int poly) -{ - unsigned int r; - r = 1; - while (n) { - if (n & 1) - r = mul_poly(r, a, poly); - a = mul_poly(a, a, poly); - n >>= 1; - } - return r; -} - - -/* compute log2(max(abs(tab[]))) */ -static int log2_tab(int16_t *tab, int n) -{ - int i, v; - - v = 0; - for(i=0;i<n;i++) { - v |= abs(tab[i]); - } - return av_log2(v); -} - -static void lshift_tab(int16_t *tab, int n, int lshift) -{ - int i; - - if (lshift > 0) { - for(i=0;i<n;i++) { - tab[i] <<= lshift; - } - } else if (lshift < 0) { - lshift = -lshift; - for(i=0;i<n;i++) { - tab[i] >>= lshift; - } - } -} - -/* fill the end of the frame and compute the two crcs */ -static int output_frame_end(AC3EncodeContext *s) -{ - int frame_size, frame_size_58, n, crc1, crc2, crc_inv; - uint8_t *frame; - - frame_size = s->frame_size; /* frame size in words */ - /* align to 8 bits */ - flush_put_bits(&s->pb); - /* add zero bytes to reach the frame size */ - frame = s->pb.buf; - n = 2 * s->frame_size - (pbBufPtr(&s->pb) - frame) - 2; - assert(n >= 0); - if(n>0) - memset(pbBufPtr(&s->pb), 0, n); - - /* Now we must compute both crcs : this is not so easy for crc1 - because it is at the beginning of the data... */ - frame_size_58 = (frame_size >> 1) + (frame_size >> 3); - crc1 = bswap_16(av_crc(av_crc8005, 0, frame + 4, 2 * frame_size_58 - 4)); - /* XXX: could precompute crc_inv */ - crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY); - crc1 = mul_poly(crc_inv, crc1, CRC16_POLY); - frame[2] = crc1 >> 8; - frame[3] = crc1; - - crc2 = bswap_16(av_crc(av_crc8005, 0, frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2)); - frame[2*frame_size - 2] = crc2 >> 8; - frame[2*frame_size - 1] = crc2; - - // printf("n=%d frame_size=%d\n", n, frame_size); - return frame_size * 2; -} - -static int AC3_encode_frame(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) -{ - AC3EncodeContext *s = avctx->priv_data; - int16_t *samples = data; - int i, j, k, v, ch; - int16_t input_samples[N]; - int32_t mdct_coef[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; - uint8_t exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; - uint8_t exp_strategy[NB_BLOCKS][AC3_MAX_CHANNELS]; - uint8_t encoded_exp[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; - uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; - int8_t exp_samples[NB_BLOCKS][AC3_MAX_CHANNELS]; - int frame_bits; - - frame_bits = 0; - for(ch=0;ch<s->nb_all_channels;ch++) { - /* fixed mdct to the six sub blocks & exponent computation */ - for(i=0;i<NB_BLOCKS;i++) { - int16_t *sptr; - int sinc; - - /* compute input samples */ - memcpy(input_samples, s->last_samples[ch], N/2 * sizeof(int16_t)); - sinc = s->nb_all_channels; - sptr = samples + (sinc * (N/2) * i) + ch; - for(j=0;j<N/2;j++) { - v = *sptr; - input_samples[j + N/2] = v; - s->last_samples[ch][j] = v; - sptr += sinc; - } - - /* apply the MDCT window */ - for(j=0;j<N/2;j++) { - input_samples[j] = MUL16(input_samples[j], - ac3_window[j]) >> 15; - input_samples[N-j-1] = MUL16(input_samples[N-j-1], - ac3_window[j]) >> 15; - } - - /* Normalize the samples to use the maximum available - precision */ - v = 14 - log2_tab(input_samples, N); - if (v < 0) - v = 0; - exp_samples[i][ch] = v - 9; - lshift_tab(input_samples, N, v); - - /* do the MDCT */ - mdct512(mdct_coef[i][ch], input_samples); - - /* compute "exponents". We take into account the - normalization there */ - for(j=0;j<N/2;j++) { - int e; - v = abs(mdct_coef[i][ch][j]); - if (v == 0) - e = 24; - else { - e = 23 - av_log2(v) + exp_samples[i][ch]; - if (e >= 24) { - e = 24; - mdct_coef[i][ch][j] = 0; - } - } - exp[i][ch][j] = e; - } - } - - compute_exp_strategy(exp_strategy, exp, ch, ch == s->lfe_channel); - - /* compute the exponents as the decoder will see them. The - EXP_REUSE case must be handled carefully : we select the - min of the exponents */ - i = 0; - while (i < NB_BLOCKS) { - j = i + 1; - while (j < NB_BLOCKS && exp_strategy[j][ch] == EXP_REUSE) { - exponent_min(exp[i][ch], exp[j][ch], s->nb_coefs[ch]); - j++; - } - frame_bits += encode_exp(encoded_exp[i][ch], - exp[i][ch], s->nb_coefs[ch], - exp_strategy[i][ch]); - /* copy encoded exponents for reuse case */ - for(k=i+1;k<j;k++) { - memcpy(encoded_exp[k][ch], encoded_exp[i][ch], - s->nb_coefs[ch] * sizeof(uint8_t)); - } - i = j; - } - } - - /* adjust for fractional frame sizes */ - while(s->bits_written >= s->bit_rate*1000 && s->samples_written >= s->sample_rate) { - s->bits_written -= s->bit_rate*1000; - s->samples_written -= s->sample_rate; - } - s->frame_size = s->frame_size_min + (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate*1000); - s->bits_written += s->frame_size * 16; - s->samples_written += AC3_FRAME_SIZE; - - compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits); - /* everything is known... let's output the frame */ - output_frame_header(s, frame); - - for(i=0;i<NB_BLOCKS;i++) { - output_audio_block(s, exp_strategy[i], encoded_exp[i], - bap[i], mdct_coef[i], exp_samples[i], i); - } - return output_frame_end(s); -} - -static int AC3_encode_close(AVCodecContext *avctx) -{ - av_freep(&avctx->coded_frame); - return 0; -} - -#if 0 -/*************************************************************************/ -/* TEST */ - -#define FN (N/4) - -void fft_test(void) -{ - IComplex in[FN], in1[FN]; - int k, n, i; - float sum_re, sum_im, a; - - /* FFT test */ - - for(i=0;i<FN;i++) { - in[i].re = random() % 65535 - 32767; - in[i].im = random() % 65535 - 32767; - in1[i] = in[i]; - } - fft(in, 7); - - /* do it by hand */ - for(k=0;k<FN;k++) { - sum_re = 0; - sum_im = 0; - for(n=0;n<FN;n++) { - a = -2 * M_PI * (n * k) / FN; - sum_re += in1[n].re * cos(a) - in1[n].im * sin(a); - sum_im += in1[n].re * sin(a) + in1[n].im * cos(a); - } - printf("%3d: %6d,%6d %6.0f,%6.0f\n", - k, in[k].re, in[k].im, sum_re / FN, sum_im / FN); - } -} - -void mdct_test(void) -{ - int16_t input[N]; - int32_t output[N/2]; - float input1[N]; - float output1[N/2]; - float s, a, err, e, emax; - int i, k, n; - - for(i=0;i<N;i++) { - input[i] = (random() % 65535 - 32767) * 9 / 10; - input1[i] = input[i]; - } - - mdct512(output, input); - - /* do it by hand */ - for(k=0;k<N/2;k++) { - s = 0; - for(n=0;n<N;n++) { - a = (2*M_PI*(2*n+1+N/2)*(2*k+1) / (4 * N)); - s += input1[n] * cos(a); - } - output1[k] = -2 * s / N; - } - - err = 0; - emax = 0; - for(i=0;i<N/2;i++) { - printf("%3d: %7d %7.0f\n", i, output[i], output1[i]); - e = output[i] - output1[i]; - if (e > emax) - emax = e; - err += e * e; - } - printf("err2=%f emax=%f\n", err / (N/2), emax); -} - -void test_ac3(void) -{ - AC3EncodeContext ctx; - unsigned char frame[AC3_MAX_CODED_FRAME_SIZE]; - short samples[AC3_FRAME_SIZE]; - int ret, i; - - AC3_encode_init(&ctx, 44100, 64000, 1); - - fft_test(); - mdct_test(); - - for(i=0;i<AC3_FRAME_SIZE;i++) - samples[i] = (int)(sin(2*M_PI*i*1000.0/44100) * 10000); - ret = AC3_encode_frame(&ctx, frame, samples); - printf("ret=%d\n", ret); -} -#endif - -AVCodec ac3_encoder = { - "ac3", - CODEC_TYPE_AUDIO, - CODEC_ID_AC3, - sizeof(AC3EncodeContext), - AC3_encode_init, - AC3_encode_frame, - AC3_encode_close, - NULL, -};
--- a/src/ffmpeg/libavcodec/dvbsub.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,445 +0,0 @@ -/* - * DVB subtitle encoding for ffmpeg - * Copyright (c) 2005 Fabrice Bellard. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "avcodec.h" - -typedef struct DVBSubtitleContext { - int hide_state; - int object_version; -} DVBSubtitleContext; - -#define PUTBITS2(val)\ -{\ - bitbuf |= (val) << bitcnt;\ - bitcnt -= 2;\ - if (bitcnt < 0) {\ - bitcnt = 6;\ - *q++ = bitbuf;\ - bitbuf = 0;\ - }\ -} - -static void dvb_encode_rle2(uint8_t **pq, - const uint8_t *bitmap, int linesize, - int w, int h) -{ - uint8_t *q; - unsigned int bitbuf; - int bitcnt; - int x, y, len, x1, v, color; - - q = *pq; - - for(y = 0; y < h; y++) { - *q++ = 0x10; - bitbuf = 0; - bitcnt = 6; - - x = 0; - while (x < w) { - x1 = x; - color = bitmap[x1++]; - while (x1 < w && bitmap[x1] == color) - x1++; - len = x1 - x; - if (color == 0 && len == 2) { - PUTBITS2(0); - PUTBITS2(0); - PUTBITS2(1); - } else if (len >= 3 && len <= 10) { - v = len - 3; - PUTBITS2(0); - PUTBITS2((v >> 2) | 2); - PUTBITS2(v & 3); - PUTBITS2(color); - } else if (len >= 12 && len <= 27) { - v = len - 12; - PUTBITS2(0); - PUTBITS2(0); - PUTBITS2(2); - PUTBITS2(v >> 2); - PUTBITS2(v & 3); - PUTBITS2(color); - } else if (len >= 29) { - /* length = 29 ... 284 */ - if (len > 284) - len = 284; - v = len - 29; - PUTBITS2(0); - PUTBITS2(0); - PUTBITS2(3); - PUTBITS2((v >> 6)); - PUTBITS2((v >> 4) & 3); - PUTBITS2((v >> 2) & 3); - PUTBITS2(v & 3); - PUTBITS2(color); - } else { - PUTBITS2(color); - if (color == 0) { - PUTBITS2(1); - } - len = 1; - } - x += len; - } - /* end of line */ - PUTBITS2(0); - PUTBITS2(0); - PUTBITS2(0); - if (bitcnt != 6) { - *q++ = bitbuf; - } - *q++ = 0xf0; - bitmap += linesize; - } - *pq = q; -} - -#define PUTBITS4(val)\ -{\ - bitbuf |= (val) << bitcnt;\ - bitcnt -= 4;\ - if (bitcnt < 0) {\ - bitcnt = 4;\ - *q++ = bitbuf;\ - bitbuf = 0;\ - }\ -} - -/* some DVB decoders only implement 4 bits/pixel */ -static void dvb_encode_rle4(uint8_t **pq, - const uint8_t *bitmap, int linesize, - int w, int h) -{ - uint8_t *q; - unsigned int bitbuf; - int bitcnt; - int x, y, len, x1, v, color; - - q = *pq; - - for(y = 0; y < h; y++) { - *q++ = 0x11; - bitbuf = 0; - bitcnt = 4; - - x = 0; - while (x < w) { - x1 = x; - color = bitmap[x1++]; - while (x1 < w && bitmap[x1] == color) - x1++; - len = x1 - x; - if (color == 0 && len == 2) { - PUTBITS4(0); - PUTBITS4(0xd); - } else if (color == 0 && (len >= 3 && len <= 9)) { - PUTBITS4(0); - PUTBITS4(len - 2); - } else if (len >= 4 && len <= 7) { - PUTBITS4(0); - PUTBITS4(8 + len - 4); - PUTBITS4(color); - } else if (len >= 9 && len <= 24) { - PUTBITS4(0); - PUTBITS4(0xe); - PUTBITS4(len - 9); - PUTBITS4(color); - } else if (len >= 25) { - if (len > 280) - len = 280; - v = len - 25; - PUTBITS4(0); - PUTBITS4(0xf); - PUTBITS4(v >> 4); - PUTBITS4(v & 0xf); - PUTBITS4(color); - } else { - PUTBITS4(color); - if (color == 0) { - PUTBITS4(0xc); - } - len = 1; - } - x += len; - } - /* end of line */ - PUTBITS4(0); - PUTBITS4(0); - if (bitcnt != 4) { - *q++ = bitbuf; - } - *q++ = 0xf0; - bitmap += linesize; - } - *pq = q; -} - -#define SCALEBITS 10 -#define ONE_HALF (1 << (SCALEBITS - 1)) -#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5)) - -#define RGB_TO_Y_CCIR(r, g, b) \ -((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \ - FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS) - -#define RGB_TO_U_CCIR(r1, g1, b1, shift)\ -(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 + \ - FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) - -#define RGB_TO_V_CCIR(r1, g1, b1, shift)\ -(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 - \ - FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128) - -static inline void putbe16(uint8_t **pq, uint16_t v) -{ - uint8_t *q; - q = *pq; - *q++ = v >> 8; - *q++ = v; - *pq = q; -} - -static int encode_dvb_subtitles(DVBSubtitleContext *s, - uint8_t *outbuf, AVSubtitle *h) -{ - uint8_t *q, *pseg_len; - int page_id, region_id, clut_id, object_id, i, bpp_index, page_state; - - - q = outbuf; - - page_id = 1; - - if (h->num_rects == 0 || h->rects == NULL) - return -1; - - *q++ = 0x00; /* subtitle_stream_id */ - - /* page composition segment */ - - *q++ = 0x0f; /* sync_byte */ - *q++ = 0x10; /* segment_type */ - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - *q++ = 30; /* page_timeout (seconds) */ - if (s->hide_state) - page_state = 0; /* normal case */ - else - page_state = 2; /* mode change */ - /* page_version = 0 + page_state */ - *q++ = s->object_version | (page_state << 2) | 3; - - for (region_id = 0; region_id < h->num_rects; region_id++) { - *q++ = region_id; - *q++ = 0xff; /* reserved */ - putbe16(&q, h->rects[region_id].x); /* left pos */ - putbe16(&q, h->rects[region_id].y); /* top pos */ - } - - putbe16(&pseg_len, q - pseg_len - 2); - - if (!s->hide_state) { - for (clut_id = 0; clut_id < h->num_rects; clut_id++) { - - /* CLUT segment */ - - if (h->rects[clut_id].nb_colors <= 4) { - /* 2 bpp, some decoders do not support it correctly */ - bpp_index = 0; - } else if (h->rects[clut_id].nb_colors <= 16) { - /* 4 bpp, standard encoding */ - bpp_index = 1; - } else { - return -1; - } - - *q++ = 0x0f; /* sync byte */ - *q++ = 0x12; /* CLUT definition segment */ - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - *q++ = clut_id; - *q++ = (0 << 4) | 0xf; /* version = 0 */ - - for(i = 0; i < h->rects[clut_id].nb_colors; i++) { - *q++ = i; /* clut_entry_id */ - *q++ = (1 << (7 - bpp_index)) | (0xf << 1) | 1; /* 2 bits/pixel full range */ - { - int a, r, g, b; - a = (h->rects[clut_id].rgba_palette[i] >> 24) & 0xff; - r = (h->rects[clut_id].rgba_palette[i] >> 16) & 0xff; - g = (h->rects[clut_id].rgba_palette[i] >> 8) & 0xff; - b = (h->rects[clut_id].rgba_palette[i] >> 0) & 0xff; - - *q++ = RGB_TO_Y_CCIR(r, g, b); - *q++ = RGB_TO_V_CCIR(r, g, b, 0); - *q++ = RGB_TO_U_CCIR(r, g, b, 0); - *q++ = 255 - a; - } - } - - putbe16(&pseg_len, q - pseg_len - 2); - } - } - - for (region_id = 0; region_id < h->num_rects; region_id++) { - - /* region composition segment */ - - if (h->rects[region_id].nb_colors <= 4) { - /* 2 bpp, some decoders do not support it correctly */ - bpp_index = 0; - } else if (h->rects[region_id].nb_colors <= 16) { - /* 4 bpp, standard encoding */ - bpp_index = 1; - } else { - return -1; - } - - *q++ = 0x0f; /* sync_byte */ - *q++ = 0x11; /* segment_type */ - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - *q++ = region_id; - *q++ = (s->object_version << 4) | (0 << 3) | 0x07; /* version , no fill */ - putbe16(&q, h->rects[region_id].w); /* region width */ - putbe16(&q, h->rects[region_id].h); /* region height */ - *q++ = ((1 + bpp_index) << 5) | ((1 + bpp_index) << 2) | 0x03; - *q++ = region_id; /* clut_id == region_id */ - *q++ = 0; /* 8 bit fill colors */ - *q++ = 0x03; /* 4 bit and 2 bit fill colors */ - - if (!s->hide_state) { - putbe16(&q, region_id); /* object_id == region_id */ - *q++ = (0 << 6) | (0 << 4); - *q++ = 0; - *q++ = 0xf0; - *q++ = 0; - } - - putbe16(&pseg_len, q - pseg_len - 2); - } - - if (!s->hide_state) { - - for (object_id = 0; object_id < h->num_rects; object_id++) { - /* Object Data segment */ - - if (h->rects[object_id].nb_colors <= 4) { - /* 2 bpp, some decoders do not support it correctly */ - bpp_index = 0; - } else if (h->rects[object_id].nb_colors <= 16) { - /* 4 bpp, standard encoding */ - bpp_index = 1; - } else { - return -1; - } - - *q++ = 0x0f; /* sync byte */ - *q++ = 0x13; - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - - putbe16(&q, object_id); - *q++ = (s->object_version << 4) | (0 << 2) | (0 << 1) | 1; /* version = 0, - onject_coding_method, - non_modifying_color_flag */ - { - uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr; - void (*dvb_encode_rle)(uint8_t **pq, - const uint8_t *bitmap, int linesize, - int w, int h); - ptop_field_len = q; - q += 2; - pbottom_field_len = q; - q += 2; - - if (bpp_index == 0) - dvb_encode_rle = dvb_encode_rle2; - else - dvb_encode_rle = dvb_encode_rle4; - - top_ptr = q; - dvb_encode_rle(&q, h->rects[object_id].bitmap, h->rects[object_id].w * 2, - h->rects[object_id].w, h->rects[object_id].h >> 1); - bottom_ptr = q; - dvb_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w, - h->rects[object_id].w * 2, h->rects[object_id].w, - h->rects[object_id].h >> 1); - - putbe16(&ptop_field_len, bottom_ptr - top_ptr); - putbe16(&pbottom_field_len, q - bottom_ptr); - } - - putbe16(&pseg_len, q - pseg_len - 2); - } - } - - /* end of display set segment */ - - *q++ = 0x0f; /* sync_byte */ - *q++ = 0x80; /* segment_type */ - putbe16(&q, page_id); - pseg_len = q; - q += 2; /* segment length */ - - putbe16(&pseg_len, q - pseg_len - 2); - - *q++ = 0xff; /* end of PES data */ - - s->object_version = (s->object_version + 1) & 0xf; - s->hide_state = !s->hide_state; - return q - outbuf; -} - -static int dvbsub_init_decoder(AVCodecContext *avctx) -{ - return 0; -} - -static int dvbsub_close_decoder(AVCodecContext *avctx) -{ - return 0; -} - -static int dvbsub_encode(AVCodecContext *avctx, - unsigned char *buf, int buf_size, void *data) -{ - DVBSubtitleContext *s = avctx->priv_data; - AVSubtitle *sub = data; - int ret; - - ret = encode_dvb_subtitles(s, buf, sub); - return ret; -} - -AVCodec dvbsub_encoder = { - "dvbsub", - CODEC_TYPE_SUBTITLE, - CODEC_ID_DVB_SUBTITLE, - sizeof(DVBSubtitleContext), - dvbsub_init_decoder, - dvbsub_encode, - dvbsub_close_decoder, -};
--- a/src/ffmpeg/libavcodec/dvbsubdec.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1633 +0,0 @@ -/* - * DVB subtitle decoding for ffmpeg - * Copyright (c) 2005 Ian Caulfield. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "avcodec.h" -#include "dsputil.h" -#include "bitstream.h" - -//#define DEBUG -//#define DEBUG_PACKET_CONTENTS -//#define DEBUG_SAVE_IMAGES - -#define DVBSUB_PAGE_SEGMENT 0x10 -#define DVBSUB_REGION_SEGMENT 0x11 -#define DVBSUB_CLUT_SEGMENT 0x12 -#define DVBSUB_OBJECT_SEGMENT 0x13 -#define DVBSUB_DISPLAY_SEGMENT 0x80 - -static unsigned char *cm; - -#ifdef DEBUG_SAVE_IMAGES -#undef fprintf -#if 0 -static void png_save(const char *filename, uint8_t *bitmap, int w, int h, - uint32_t *rgba_palette) -{ - int x, y, v; - FILE *f; - char fname[40], fname2[40]; - char command[1024]; - - snprintf(fname, 40, "%s.ppm", filename); - - f = fopen(fname, "w"); - if (!f) { - perror(fname); - exit(1); - } - fprintf(f, "P6\n" - "%d %d\n" - "%d\n", - w, h, 255); - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) { - v = rgba_palette[bitmap[y * w + x]]; - putc((v >> 16) & 0xff, f); - putc((v >> 8) & 0xff, f); - putc((v >> 0) & 0xff, f); - } - } - fclose(f); - - - snprintf(fname2, 40, "%s-a.pgm", filename); - - f = fopen(fname2, "w"); - if (!f) { - perror(fname2); - exit(1); - } - fprintf(f, "P5\n" - "%d %d\n" - "%d\n", - w, h, 255); - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) { - v = rgba_palette[bitmap[y * w + x]]; - putc((v >> 24) & 0xff, f); - } - } - fclose(f); - - snprintf(command, 1024, "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename); - system(command); - - snprintf(command, 1024, "rm %s %s", fname, fname2); - system(command); -} -#endif - -static void png_save2(const char *filename, uint32_t *bitmap, int w, int h) -{ - int x, y, v; - FILE *f; - char fname[40], fname2[40]; - char command[1024]; - - snprintf(fname, 40, "%s.ppm", filename); - - f = fopen(fname, "w"); - if (!f) { - perror(fname); - exit(1); - } - fprintf(f, "P6\n" - "%d %d\n" - "%d\n", - w, h, 255); - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) { - v = bitmap[y * w + x]; - putc((v >> 16) & 0xff, f); - putc((v >> 8) & 0xff, f); - putc((v >> 0) & 0xff, f); - } - } - fclose(f); - - - snprintf(fname2, 40, "%s-a.pgm", filename); - - f = fopen(fname2, "w"); - if (!f) { - perror(fname2); - exit(1); - } - fprintf(f, "P5\n" - "%d %d\n" - "%d\n", - w, h, 255); - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) { - v = bitmap[y * w + x]; - putc((v >> 24) & 0xff, f); - } - } - fclose(f); - - snprintf(command, 1024, "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename); - system(command); - - snprintf(command, 1024, "rm %s %s", fname, fname2); - system(command); -} -#endif - -#define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) - -typedef struct DVBSubCLUT { - int id; - - uint32_t clut4[4]; - uint32_t clut16[16]; - uint32_t clut256[256]; - - struct DVBSubCLUT *next; -} DVBSubCLUT; - -static DVBSubCLUT default_clut; - -typedef struct DVBSubObjectDisplay { - int object_id; - int region_id; - - int x_pos; - int y_pos; - - int fgcolour; - int bgcolour; - - struct DVBSubObjectDisplay *region_list_next; - struct DVBSubObjectDisplay *object_list_next; -} DVBSubObjectDisplay; - -typedef struct DVBSubObject { - int id; - - int type; - - DVBSubObjectDisplay *display_list; - - struct DVBSubObject *next; -} DVBSubObject; - -typedef struct DVBSubRegionDisplay { - int region_id; - - int x_pos; - int y_pos; - - struct DVBSubRegionDisplay *next; -} DVBSubRegionDisplay; - -typedef struct DVBSubRegion { - int id; - - int width; - int height; - int depth; - - int clut; - int bgcolour; - - uint8_t *pbuf; - int buf_size; - - DVBSubObjectDisplay *display_list; - - struct DVBSubRegion *next; -} DVBSubRegion; - -typedef struct DVBSubContext { - int composition_id; - int ancillary_id; - - int time_out; - DVBSubRegion *region_list; - DVBSubCLUT *clut_list; - DVBSubObject *object_list; - - int display_list_size; - DVBSubRegionDisplay *display_list; -} DVBSubContext; - - -static DVBSubObject* get_object(DVBSubContext *ctx, int object_id) -{ - DVBSubObject *ptr = ctx->object_list; - - while (ptr != NULL && ptr->id != object_id) { - ptr = ptr->next; - } - - return ptr; -} - -static DVBSubCLUT* get_clut(DVBSubContext *ctx, int clut_id) -{ - DVBSubCLUT *ptr = ctx->clut_list; - - while (ptr != NULL && ptr->id != clut_id) { - ptr = ptr->next; - } - - return ptr; -} - -static DVBSubRegion* get_region(DVBSubContext *ctx, int region_id) -{ - DVBSubRegion *ptr = ctx->region_list; - - while (ptr != NULL && ptr->id != region_id) { - ptr = ptr->next; - } - - return ptr; -} - -static void delete_region_display_list(DVBSubContext *ctx, DVBSubRegion *region) -{ - DVBSubObject *object, *obj2, **obj2_ptr; - DVBSubObjectDisplay *display, *obj_disp, **obj_disp_ptr; - - while (region->display_list != NULL) { - display = region->display_list; - - object = get_object(ctx, display->object_id); - - if (object != NULL) { - obj_disp = object->display_list; - obj_disp_ptr = &object->display_list; - - while (obj_disp != NULL && obj_disp != display) { - obj_disp_ptr = &obj_disp->object_list_next; - obj_disp = obj_disp->object_list_next; - } - - if (obj_disp) { - *obj_disp_ptr = obj_disp->object_list_next; - - if (object->display_list == NULL) { - obj2 = ctx->object_list; - obj2_ptr = &ctx->object_list; - - while (obj2 != NULL && obj2 != object) { - obj2_ptr = &obj2->next; - obj2 = obj2->next; - } - - *obj2_ptr = obj2->next; - - av_free(obj2); - } - } - } - - region->display_list = display->region_list_next; - - av_free(display); - } - -} - -static void delete_state(DVBSubContext *ctx) -{ - DVBSubRegion *region; - DVBSubCLUT *clut; - - while (ctx->region_list != NULL) - { - region = ctx->region_list; - - ctx->region_list = region->next; - - delete_region_display_list(ctx, region); - if (region->pbuf != NULL) - av_free(region->pbuf); - - av_free(region); - } - - while (ctx->clut_list != NULL) - { - clut = ctx->clut_list; - - ctx->clut_list = clut->next; - - av_free(clut); - } - - /* Should already be null */ - if (ctx->object_list != NULL) - av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n"); -} - -static int dvbsub_init_decoder(AVCodecContext *avctx) -{ - int i, r, g, b, a = 0; - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - cm = cropTbl + MAX_NEG_CROP; - - memset(avctx->priv_data, 0, sizeof(DVBSubContext)); - - ctx->composition_id = avctx->sub_id & 0xffff; - ctx->ancillary_id = avctx->sub_id >> 16; - - default_clut.id = -1; - default_clut.next = NULL; - - default_clut.clut4[0] = RGBA( 0, 0, 0, 0); - default_clut.clut4[1] = RGBA(255, 255, 255, 255); - default_clut.clut4[2] = RGBA( 0, 0, 0, 255); - default_clut.clut4[3] = RGBA(127, 127, 127, 255); - - default_clut.clut16[0] = RGBA( 0, 0, 0, 0); - for (i = 1; i < 16; i++) { - if (i < 8) { - r = (i & 1) ? 255 : 0; - g = (i & 2) ? 255 : 0; - b = (i & 4) ? 255 : 0; - } else { - r = (i & 1) ? 127 : 0; - g = (i & 2) ? 127 : 0; - b = (i & 4) ? 127 : 0; - } - default_clut.clut16[i] = RGBA(r, g, b, 255); - } - - default_clut.clut256[0] = RGBA( 0, 0, 0, 0); - for (i = 1; i < 256; i++) { - if (i < 8) { - r = (i & 1) ? 255 : 0; - g = (i & 2) ? 255 : 0; - b = (i & 4) ? 255 : 0; - a = 63; - } else { - switch (i & 0x88) { - case 0x00: - r = ((i & 1) ? 85 : 0) + ((i & 0x10) ? 170 : 0); - g = ((i & 2) ? 85 : 0) + ((i & 0x20) ? 170 : 0); - b = ((i & 4) ? 85 : 0) + ((i & 0x40) ? 170 : 0); - a = 255; - break; - case 0x08: - r = ((i & 1) ? 85 : 0) + ((i & 0x10) ? 170 : 0); - g = ((i & 2) ? 85 : 0) + ((i & 0x20) ? 170 : 0); - b = ((i & 4) ? 85 : 0) + ((i & 0x40) ? 170 : 0); - a = 127; - break; - case 0x80: - r = 127 + ((i & 1) ? 43 : 0) + ((i & 0x10) ? 85 : 0); - g = 127 + ((i & 2) ? 43 : 0) + ((i & 0x20) ? 85 : 0); - b = 127 + ((i & 4) ? 43 : 0) + ((i & 0x40) ? 85 : 0); - a = 255; - break; - case 0x88: - r = ((i & 1) ? 43 : 0) + ((i & 0x10) ? 85 : 0); - g = ((i & 2) ? 43 : 0) + ((i & 0x20) ? 85 : 0); - b = ((i & 4) ? 43 : 0) + ((i & 0x40) ? 85 : 0); - a = 255; - break; - } - } - default_clut.clut256[i] = RGBA(r, g, b, a); - } - - return 0; -} - -static int dvbsub_close_decoder(AVCodecContext *avctx) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - DVBSubRegionDisplay *display; - - delete_state(ctx); - - while (ctx->display_list != NULL) - { - display = ctx->display_list; - ctx->display_list = display->next; - - av_free(display); - } - - return 0; -} - -static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len, - uint8_t **srcbuf, int buf_size, - int non_mod, uint8_t *map_table) -{ - GetBitContext gb; - - int bits; - int run_length; - int pixels_read = 0; - - init_get_bits(&gb, *srcbuf, buf_size << 8); - - while (get_bits_count(&gb) < (buf_size << 8) && pixels_read < dbuf_len) { - bits = get_bits(&gb, 2); - - if (bits != 0) { - if (non_mod != 1 || bits != 1) { - if (map_table != NULL) - *destbuf++ = map_table[bits]; - else - *destbuf++ = bits; - } - pixels_read++; - } else { - bits = get_bits(&gb, 1); - if (bits == 1) { - run_length = get_bits(&gb, 3) + 3; - bits = get_bits(&gb, 2); - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - else { - if (map_table != NULL) - bits = map_table[bits]; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } else { - bits = get_bits(&gb, 1); - if (bits == 0) { - bits = get_bits(&gb, 2); - if (bits == 2) { - run_length = get_bits(&gb, 4) + 12; - bits = get_bits(&gb, 2); - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - else { - if (map_table != NULL) - bits = map_table[bits]; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } else if (bits == 3) { - run_length = get_bits(&gb, 8) + 29; - bits = get_bits(&gb, 2); - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - else { - if (map_table != NULL) - bits = map_table[bits]; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } else if (bits == 1) { - pixels_read += 2; - if (map_table != NULL) - bits = map_table[0]; - else - bits = 0; - if (pixels_read <= dbuf_len) { - *destbuf++ = bits; - *destbuf++ = bits; - } - } else { - (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; - return pixels_read; - } - } else { - if (map_table != NULL) - bits = map_table[0]; - else - bits = 0; - *destbuf++ = bits; - pixels_read++; - } - } - } - } - - if (get_bits(&gb, 6) != 0) - av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); - - (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; - - return pixels_read; -} - -static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len, - uint8_t **srcbuf, int buf_size, - int non_mod, uint8_t *map_table) -{ - GetBitContext gb; - - int bits; - int run_length; - int pixels_read = 0; - - init_get_bits(&gb, *srcbuf, buf_size << 8); - - while (get_bits_count(&gb) < (buf_size << 8) && pixels_read < dbuf_len) { - bits = get_bits(&gb, 4); - - if (bits != 0) { - if (non_mod != 1 || bits != 1) { - if (map_table != NULL) - *destbuf++ = map_table[bits]; - else - *destbuf++ = bits; - } - pixels_read++; - } else { - bits = get_bits(&gb, 1); - if (bits == 0) { - run_length = get_bits(&gb, 3); - - if (run_length == 0) { - (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; - return pixels_read; - } - - run_length += 2; - - if (map_table != NULL) - bits = map_table[0]; - else - bits = 0; - - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } else { - bits = get_bits(&gb, 1); - if (bits == 0) { - run_length = get_bits(&gb, 2) + 4; - bits = get_bits(&gb, 4); - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - else { - if (map_table != NULL) - bits = map_table[bits]; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } else { - bits = get_bits(&gb, 2); - if (bits == 2) { - run_length = get_bits(&gb, 4) + 9; - bits = get_bits(&gb, 4); - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - else { - if (map_table != NULL) - bits = map_table[bits]; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } else if (bits == 3) { - run_length = get_bits(&gb, 8) + 25; - bits = get_bits(&gb, 4); - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - else { - if (map_table != NULL) - bits = map_table[bits]; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } else if (bits == 1) { - pixels_read += 2; - if (map_table != NULL) - bits = map_table[0]; - else - bits = 0; - if (pixels_read <= dbuf_len) { - *destbuf++ = bits; - *destbuf++ = bits; - } - } else { - if (map_table != NULL) - bits = map_table[0]; - else - bits = 0; - *destbuf++ = bits; - pixels_read ++; - } - } - } - } - } - - if (get_bits(&gb, 8) != 0) - av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); - - (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; - - return pixels_read; -} - -static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len, - uint8_t **srcbuf, int buf_size, - int non_mod, uint8_t *map_table) -{ - uint8_t *sbuf_end = (*srcbuf) + buf_size; - int bits; - int run_length; - int pixels_read = 0; - - while (*srcbuf < sbuf_end && pixels_read < dbuf_len) { - bits = *(*srcbuf)++; - - if (bits != 0) { - if (non_mod != 1 || bits != 1) { - if (map_table != NULL) - *destbuf++ = map_table[bits]; - else - *destbuf++ = bits; - } - pixels_read++; - } else { - bits = *(*srcbuf)++; - run_length = bits & 0x7f; - if ((bits & 0x80) == 0) { - if (run_length == 0) { - return pixels_read; - } - - if (map_table != NULL) - bits = map_table[0]; - else - bits = 0; - while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } else { - bits = *(*srcbuf)++; - - if (non_mod == 1 && bits == 1) - pixels_read += run_length; - if (map_table != NULL) - bits = map_table[bits]; - else while (run_length-- > 0 && pixels_read < dbuf_len) { - *destbuf++ = bits; - pixels_read++; - } - } - } - } - - if (*(*srcbuf)++ != 0) - av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); - - return pixels_read; -} - - - -static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDisplay *display, - uint8_t *buf, int buf_size, int top_bottom, int non_mod) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - DVBSubRegion *region = get_region(ctx, display->region_id); - uint8_t *buf_end = buf + buf_size; - uint8_t *pbuf; - int x_pos, y_pos; - int i; - - uint8_t map2to4[] = { 0x0, 0x7, 0x8, 0xf}; - uint8_t map2to8[] = {0x00, 0x77, 0x88, 0xff}; - uint8_t map4to8[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; - uint8_t *map_table; - -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "DVB pixel block size %d, %s field:\n", buf_size, - top_bottom ? "bottom" : "top"); -#endif - -#ifdef DEBUG_PACKET_CONTENTS - for (i = 0; i < buf_size; i++) - { - if (i % 16 == 0) - av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i); - - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); - if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); - } - - if (i % 16 != 0) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif - - if (region == 0) - return; - - pbuf = region->pbuf; - - x_pos = display->x_pos; - y_pos = display->y_pos; - - if ((y_pos & 1) != top_bottom) - y_pos++; - - while (buf < buf_end) { - if (x_pos > region->width || y_pos > region->height) { - av_log(avctx, AV_LOG_ERROR, "Invalid object location!\n"); - return; - } - - switch (*buf++) { - case 0x10: - if (region->depth == 8) - map_table = map2to8; - else if (region->depth == 4) - map_table = map2to4; - else - map_table = NULL; - - x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + x_pos, - region->width - x_pos, &buf, buf_size, - non_mod, map_table); - break; - case 0x11: - if (region->depth < 4) { - av_log(avctx, AV_LOG_ERROR, "4-bit pixel string in %d-bit region!\n", region->depth); - return; - } - - if (region->depth == 8) - map_table = map4to8; - else - map_table = NULL; - - x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + x_pos, - region->width - x_pos, &buf, buf_size, - non_mod, map_table); - break; - case 0x12: - if (region->depth < 8) { - av_log(avctx, AV_LOG_ERROR, "8-bit pixel string in %d-bit region!\n", region->depth); - return; - } - - x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + x_pos, - region->width - x_pos, &buf, buf_size, - non_mod, NULL); - break; - - case 0x20: - map2to4[0] = (*buf) >> 4; - map2to4[1] = (*buf++) & 0xf; - map2to4[2] = (*buf) >> 4; - map2to4[3] = (*buf++) & 0xf; - break; - case 0x21: - for (i = 0; i < 4; i++) - map2to8[i] = *buf++; - break; - case 0x22: - for (i = 0; i < 16; i++) - map4to8[i] = *buf++; - break; - - case 0xf0: - x_pos = display->x_pos; - y_pos += 2; - break; - default: - av_log(avctx, AV_LOG_INFO, "Unknown/unsupported pixel block 0x%x\n", *(buf-1)); - } - } - -} - -static void dvbsub_parse_object_segment(AVCodecContext *avctx, - uint8_t *buf, int buf_size) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - uint8_t *buf_end = buf + buf_size; - uint8_t *block; - int object_id; - DVBSubObject *object; - DVBSubObjectDisplay *display; - int top_field_len, bottom_field_len; - - int coding_method, non_modifying_colour; - - object_id = BE_16(buf); - buf += 2; - - object = get_object(ctx, object_id); - - if (!object) - return; - - coding_method = ((*buf) >> 2) & 3; - non_modifying_colour = ((*buf++) >> 1) & 1; - - if (coding_method == 0) { - top_field_len = BE_16(buf); - buf += 2; - bottom_field_len = BE_16(buf); - buf += 2; - - if (buf + top_field_len + bottom_field_len > buf_end) { - av_log(avctx, AV_LOG_ERROR, "Field data size too large\n"); - return; - } - - for (display = object->display_list; display != 0; display = display->object_list_next) { - block = buf; - - dvbsub_parse_pixel_data_block(avctx, display, block, top_field_len, 0, - non_modifying_colour); - - if (bottom_field_len > 0) - block = buf + top_field_len; - else - bottom_field_len = top_field_len; - - dvbsub_parse_pixel_data_block(avctx, display, block, bottom_field_len, 1, - non_modifying_colour); - } - -/* } else if (coding_method == 1) {*/ - - } else { - av_log(avctx, AV_LOG_ERROR, "Unknown object coding %d\n", coding_method); - } - -} - -#define SCALEBITS 10 -#define ONE_HALF (1 << (SCALEBITS - 1)) -#define FIX(x) ((int) ((x) * (1<<SCALEBITS) + 0.5)) - -#define YUV_TO_RGB1_CCIR(cb1, cr1)\ -{\ - cb = (cb1) - 128;\ - cr = (cr1) - 128;\ - r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\ - g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \ - ONE_HALF;\ - b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\ -} - -#define YUV_TO_RGB2_CCIR(r, g, b, y1)\ -{\ - y = ((y1) - 16) * FIX(255.0/219.0);\ - r = cm[(y + r_add) >> SCALEBITS];\ - g = cm[(y + g_add) >> SCALEBITS];\ - b = cm[(y + b_add) >> SCALEBITS];\ -} - - -static void dvbsub_parse_clut_segment(AVCodecContext *avctx, - uint8_t *buf, int buf_size) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - uint8_t *buf_end = buf + buf_size; - int clut_id; - DVBSubCLUT *clut; - int entry_id, depth , full_range; - int y, cr, cb, alpha; - int r, g, b, r_add, g_add, b_add; - -#ifdef DEBUG_PACKET_CONTENTS - int i; - - av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n"); - - for (i=0; i < buf_size; i++) - { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); - if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); - } - - if (i % 16 != 0) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif - - clut_id = *buf++; - buf += 1; - - clut = get_clut(ctx, clut_id); - - if (clut == NULL) { - clut = av_malloc(sizeof(DVBSubCLUT)); - - memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); - - clut->id = clut_id; - - clut->next = ctx->clut_list; - ctx->clut_list = clut; - } - - while (buf + 4 < buf_end) - { - entry_id = *buf++; - - depth = (*buf) & 0xe0; - - if (depth == 0) { - av_log(avctx, AV_LOG_ERROR, "Invalid clut depth 0x%x!\n", *buf); - return; - } - - full_range = (*buf++) & 1; - - if (full_range) { - y = *buf++; - cr = *buf++; - cb = *buf++; - alpha = *buf++; - } else { - y = buf[0] & 0xfc; - cr = (((buf[0] & 3) << 2) | ((buf[1] >> 6) & 3)) << 4; - cb = (buf[1] << 2) & 0xf0; - alpha = (buf[1] << 6) & 0xc0; - - buf += 2; - } - - if (y == 0) - alpha = 0xff; - - YUV_TO_RGB1_CCIR(cb, cr); - YUV_TO_RGB2_CCIR(r, g, b, y); - -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha); -#endif - - if (depth & 0x80) - clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha); - if (depth & 0x40) - clut->clut16[entry_id] = RGBA(r,g,b,255 - alpha); - if (depth & 0x20) - clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); - } -} - - -static void dvbsub_parse_region_segment(AVCodecContext *avctx, - uint8_t *buf, int buf_size) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - uint8_t *buf_end = buf + buf_size; - int region_id, object_id; - DVBSubRegion *region; - DVBSubObject *object; - DVBSubObjectDisplay *display; - int fill; - - if (buf_size < 10) - return; - - region_id = *buf++; - - region = get_region(ctx, region_id); - - if (region == NULL) - { - region = av_mallocz(sizeof(DVBSubRegion)); - - region->id = region_id; - - region->next = ctx->region_list; - ctx->region_list = region; - } - - fill = ((*buf++) >> 3) & 1; - - region->width = BE_16(buf); - buf += 2; - region->height = BE_16(buf); - buf += 2; - - if (region->width * region->height != region->buf_size) { - if (region->pbuf != 0) - av_free(region->pbuf); - - region->buf_size = region->width * region->height; - - region->pbuf = av_malloc(region->buf_size); - - fill = 1; - } - - region->depth = 1 << (((*buf++) >> 2) & 7); - region->clut = *buf++; - - if (region->depth == 8) - region->bgcolour = *buf++; - else { - buf += 1; - - if (region->depth == 4) - region->bgcolour = (((*buf++) >> 4) & 15); - else - region->bgcolour = (((*buf++) >> 2) & 3); - } - -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Region %d, (%dx%d)\n", region_id, region->width, region->height); -#endif - - if (fill) { - memset(region->pbuf, region->bgcolour, region->buf_size); -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour); -#endif - } - - delete_region_display_list(ctx, region); - - while (buf + 5 < buf_end) { - object_id = BE_16(buf); - buf += 2; - - object = get_object(ctx, object_id); - - if (object == NULL) { - object = av_mallocz(sizeof(DVBSubObject)); - - object->id = object_id; - object->next = ctx->object_list; - ctx->object_list = object; - } - - object->type = (*buf) >> 6; - - display = av_mallocz(sizeof(DVBSubObjectDisplay)); - - display->object_id = object_id; - display->region_id = region_id; - - display->x_pos = BE_16(buf) & 0xfff; - buf += 2; - display->y_pos = BE_16(buf) & 0xfff; - buf += 2; - - if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) { - display->fgcolour = *buf++; - display->bgcolour = *buf++; - } - - display->region_list_next = region->display_list; - region->display_list = display; - - display->object_list_next = object->display_list; - object->display_list = display; - } -} - -static void dvbsub_parse_page_segment(AVCodecContext *avctx, - uint8_t *buf, int buf_size) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - DVBSubRegionDisplay *display; - DVBSubRegionDisplay *tmp_display_list, **tmp_ptr; - - uint8_t *buf_end = buf + buf_size; - int region_id; - int page_state; - - if (buf_size < 1) - return; - - ctx->time_out = *buf++; - page_state = ((*buf++) >> 2) & 3; - -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Page time out %ds, state %d\n", ctx->time_out, page_state); -#endif - - if (page_state == 2) - { - delete_state(ctx); - } - - tmp_display_list = ctx->display_list; - ctx->display_list = NULL; - ctx->display_list_size = 0; - - while (buf + 5 < buf_end) { - region_id = *buf++; - buf += 1; - - display = tmp_display_list; - tmp_ptr = &tmp_display_list; - - while (display != NULL && display->region_id != region_id) { - tmp_ptr = &display->next; - display = display->next; - } - - if (display == NULL) - display = av_mallocz(sizeof(DVBSubRegionDisplay)); - - display->region_id = region_id; - - display->x_pos = BE_16(buf); - buf += 2; - display->y_pos = BE_16(buf); - buf += 2; - - *tmp_ptr = display->next; - - display->next = ctx->display_list; - ctx->display_list = display; - ctx->display_list_size++; - -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos); -#endif - } - - while (tmp_display_list != 0) { - display = tmp_display_list; - - tmp_display_list = display->next; - - av_free(display); - } - -} - - -#ifdef DEBUG_SAVE_IMAGES -static void save_display_set(DVBSubContext *ctx) -{ - DVBSubRegion *region; - DVBSubRegionDisplay *display; - DVBSubCLUT *clut; - uint32_t *clut_table; - int x_pos, y_pos, width, height; - int x, y, y_off, x_off; - uint32_t *pbuf; - char filename[32]; - static int fileno_index = 0; - - x_pos = -1; - y_pos = -1; - width = 0; - height = 0; - - for (display = ctx->display_list; display != NULL; display = display->next) { - region = get_region(ctx, display->region_id); - - if (x_pos == -1) { - x_pos = display->x_pos; - y_pos = display->y_pos; - width = region->width; - height = region->height; - } else { - if (display->x_pos < x_pos) { - width += (x_pos - display->x_pos); - x_pos = display->x_pos; - } - - if (display->y_pos < y_pos) { - height += (y_pos - display->y_pos); - y_pos = display->y_pos; - } - - if (display->x_pos + region->width > x_pos + width) { - width = display->x_pos + region->width - x_pos; - } - - if (display->y_pos + region->height > y_pos + height) { - height = display->y_pos + region->height - y_pos; - } - } - } - - if (x_pos >= 0) { - - pbuf = av_malloc(width * height * 4); - - for (display = ctx->display_list; display != NULL; display = display->next) { - region = get_region(ctx, display->region_id); - - x_off = display->x_pos - x_pos; - y_off = display->y_pos - y_pos; - - clut = get_clut(ctx, region->clut); - - if (clut == 0) - clut = &default_clut; - - switch (region->depth) { - case 2: - clut_table = clut->clut4; - break; - case 8: - clut_table = clut->clut256; - break; - case 4: - default: - clut_table = clut->clut16; - break; - } - - for (y = 0; y < region->height; y++) { - for (x = 0; x < region->width; x++) { - pbuf[((y + y_off) * width) + x_off + x] = - clut_table[region->pbuf[y * region->width + x]]; - } - } - - } - - snprintf(filename, 32, "dvbs.%d", fileno_index); - - png_save2(filename, pbuf, width, height); - - av_free(pbuf); - } - - fileno_index++; -} -#endif - -static int dvbsub_display_end_segment(AVCodecContext *avctx, uint8_t *buf, - int buf_size, AVSubtitle *sub) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - - DVBSubRegion *region; - DVBSubRegionDisplay *display; - AVSubtitleRect *rect; - DVBSubCLUT *clut; - uint32_t *clut_table; - int i; - - sub->rects = NULL; - sub->start_display_time = 0; - sub->end_display_time = ctx->time_out * 1000; - sub->format = 0; - - sub->num_rects = ctx->display_list_size; - - if (sub->num_rects > 0) - sub->rects = av_mallocz(sizeof(AVSubtitleRect) * sub->num_rects); - - i = 0; - - for (display = ctx->display_list; display != NULL; display = display->next) { - region = get_region(ctx, display->region_id); - rect = &sub->rects[i]; - - if (region == NULL) - continue; - - rect->x = display->x_pos; - rect->y = display->y_pos; - rect->w = region->width; - rect->h = region->height; - rect->nb_colors = 16; - rect->linesize = region->width; - - clut = get_clut(ctx, region->clut); - - if (clut == NULL) - clut = &default_clut; - - switch (region->depth) { - case 2: - clut_table = clut->clut4; - break; - case 8: - clut_table = clut->clut256; - break; - case 4: - default: - clut_table = clut->clut16; - break; - } - - rect->rgba_palette = av_malloc((1 << region->depth) * sizeof(uint32_t)); - memcpy(rect->rgba_palette, clut_table, (1 << region->depth) * sizeof(uint32_t)); - - rect->bitmap = av_malloc(region->buf_size); - memcpy(rect->bitmap, region->pbuf, region->buf_size); - - i++; - } - - sub->num_rects = i; - -#ifdef DEBUG_SAVE_IMAGES - save_display_set(ctx); -#endif - - return 1; -} - -static int dvbsub_decode(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; - AVSubtitle *sub = (AVSubtitle*) data; - uint8_t *p, *p_end; - int segment_type; - int page_id; - int segment_length; - -#ifdef DEBUG_PACKET_CONTENTS - int i; - - av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n"); - - for (i=0; i < buf_size; i++) - { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); - if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); - } - - if (i % 16 != 0) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif - - if (buf_size <= 2) - return -1; - - p = buf; - p_end = buf + buf_size; - - while (p < p_end && *p == 0x0f) - { - p += 1; - segment_type = *p++; - page_id = BE_16(p); - p += 2; - segment_length = BE_16(p); - p += 2; - - if (page_id == ctx->composition_id || page_id == ctx->ancillary_id) { - switch (segment_type) { - case DVBSUB_PAGE_SEGMENT: - dvbsub_parse_page_segment(avctx, p, segment_length); - break; - case DVBSUB_REGION_SEGMENT: - dvbsub_parse_region_segment(avctx, p, segment_length); - break; - case DVBSUB_CLUT_SEGMENT: - dvbsub_parse_clut_segment(avctx, p, segment_length); - break; - case DVBSUB_OBJECT_SEGMENT: - dvbsub_parse_object_segment(avctx, p, segment_length); - break; - case DVBSUB_DISPLAY_SEGMENT: - *data_size = dvbsub_display_end_segment(avctx, p, segment_length, sub); - break; - default: -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Subtitling segment type 0x%x, page id %d, length %d\n", - segment_type, page_id, segment_length); -#endif - break; - } - } - - p += segment_length; - } - - if (p != p_end) - { -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Junk at end of packet\n"); -#endif - return -1; - } - - return buf_size; -} - - -AVCodec dvbsub_decoder = { - "dvbsub", - CODEC_TYPE_SUBTITLE, - CODEC_ID_DVB_SUBTITLE, - sizeof(DVBSubContext), - dvbsub_init_decoder, - NULL, - dvbsub_close_decoder, - dvbsub_decode, -}; - -/* Parser (mostly) copied from dvdsub.c */ - -#define PARSE_BUF_SIZE (65536) - - -/* parser definition */ -typedef struct DVBSubParseContext { - uint8_t *packet_buf; - int packet_start; - int packet_index; - int in_packet; -} DVBSubParseContext; - -static int dvbsub_parse_init(AVCodecParserContext *s) -{ - DVBSubParseContext *pc = s->priv_data; - pc->packet_buf = av_malloc(PARSE_BUF_SIZE); - - return 0; -} - -static int dvbsub_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - DVBSubParseContext *pc = s->priv_data; - uint8_t *p, *p_end; - int len, buf_pos = 0; - -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "DVB parse packet pts=%Lx, lpts=%Lx, cpts=%Lx:\n", - s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); -#endif - -#ifdef DEBUG_PACKET_CONTENTS - int i; - - for (i=0; i < buf_size; i++) - { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); - if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); - } - - if (i % 16 != 0) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif - - *poutbuf = NULL; - *poutbuf_size = 0; - - s->fetch_timestamp = 1; - - if (s->last_pts != s->pts && s->last_pts != AV_NOPTS_VALUE) /* Start of a new packet */ - { - if (pc->packet_index != pc->packet_start) - { -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Discarding %d bytes\n", - pc->packet_index - pc->packet_start); -#endif - } - - pc->packet_start = 0; - pc->packet_index = 0; - - if (buf_size < 2 || buf[0] != 0x20 || buf[1] != 0x00) { -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Bad packet header\n"); -#endif - return -1; - } - - buf_pos = 2; - - pc->in_packet = 1; - } else { - if (pc->packet_start != 0) - { - if (pc->packet_index != pc->packet_start) - { - memmove(pc->packet_buf, pc->packet_buf + pc->packet_start, - pc->packet_index - pc->packet_start); - - pc->packet_index -= pc->packet_start; - pc->packet_start = 0; - } else { - pc->packet_start = 0; - pc->packet_index = 0; - } - } - } - - if (buf_size - buf_pos + pc->packet_index > PARSE_BUF_SIZE) - return -1; - -/* if not currently in a packet, discard data */ - if (pc->in_packet == 0) - return buf_size; - - memcpy(pc->packet_buf + pc->packet_index, buf + buf_pos, buf_size - buf_pos); - pc->packet_index += buf_size - buf_pos; - - p = pc->packet_buf; - p_end = pc->packet_buf + pc->packet_index; - - while (p < p_end) - { - if (*p == 0x0f) - { - if (p + 6 <= p_end) - { - len = BE_16(p + 4); - - if (p + len + 6 <= p_end) - { - *poutbuf_size += len + 6; - - p += len + 6; - } else - break; - } else - break; - } else if (*p == 0xff) { - if (p + 1 < p_end) - { -#ifdef DEBUG - av_log(avctx, AV_LOG_INFO, "Junk at end of packet\n"); -#endif - } - pc->packet_index = p - pc->packet_buf; - pc->in_packet = 0; - break; - } else { - av_log(avctx, AV_LOG_ERROR, "Junk in packet\n"); - - pc->packet_index = p - pc->packet_buf; - pc->in_packet = 0; - break; - } - } - - if (*poutbuf_size > 0) - { - *poutbuf = pc->packet_buf; - pc->packet_start = *poutbuf_size; - } - - if (s->last_pts == AV_NOPTS_VALUE) - s->last_pts = s->pts; - - return buf_size; -} - -static void dvbsub_parse_close(AVCodecParserContext *s) -{ - DVBSubParseContext *pc = s->priv_data; - av_freep(&pc->packet_buf); -} - -AVCodecParser dvbsub_parser = { - { CODEC_ID_DVB_SUBTITLE }, - sizeof(DVBSubParseContext), - dvbsub_parse_init, - dvbsub_parse, - dvbsub_parse_close, -};
--- a/src/ffmpeg/libavcodec/dvdata.h Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2724 +0,0 @@ -/* - * Constants for DV codec - * Copyright (c) 2002 Fabrice Bellard. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file dvdata.h - * Constants for DV codec. - */ - -/* - * DVprofile is used to express the differences between various - * DV flavors. For now it's primarily used for differentiating - * 525/60 and 625/50, but the plans are to use it for various - * DV specs as well (e.g. SMPTE314M vs. IEC 61834). - */ -typedef struct DVprofile { - int dsf; /* value of the dsf in the DV header */ - int frame_size; /* total size of one frame in bytes */ - int difseg_size; /* number of DIF segments per DIF channel */ - int n_difchan; /* number of DIF channels per frame */ - int frame_rate; - int frame_rate_base; - int ltc_divisor; /* FPS from the LTS standpoint */ - int height; /* picture height in pixels */ - int width; /* picture width in pixels */ - AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */ - const uint16_t *video_place; /* positions of all DV macro blocks */ - enum PixelFormat pix_fmt; /* picture pixel format */ - - int audio_stride; /* size of audio_shuffle table */ - int audio_min_samples[3];/* min ammount of audio samples */ - /* for 48Khz, 44.1Khz and 32Khz */ - int audio_samples_dist[5];/* how many samples are supposed to be */ - /* in each frame in a 5 frames window */ - const uint16_t (*audio_shuffle)[9]; /* PCM shuffling table */ -} DVprofile; - -#define NB_DV_VLC 409 - -/* - * There's a catch about the following three tables: the mapping they establish - * between (run, level) and vlc is not 1-1. So you have to watch out for that - * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82. - */ -static const uint16_t dv_vlc_bits[409] = { - 0x0000, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016, - 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a, - 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2, - 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea, - 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x01e0, 0x01e1, 0x01e2, - 0x01e3, 0x01e4, 0x01e5, 0x01e6, 0x01e7, 0x01e8, 0x01e9, 0x01ea, - 0x01eb, 0x01ec, 0x01ed, 0x01ee, 0x01ef, 0x03e0, 0x03e1, 0x03e2, - 0x03e3, 0x03e4, 0x03e5, 0x03e6, 0x07ce, 0x07cf, 0x07d0, 0x07d1, - 0x07d2, 0x07d3, 0x07d4, 0x07d5, 0x0fac, 0x0fad, 0x0fae, 0x0faf, - 0x0fb0, 0x0fb1, 0x0fb2, 0x0fb3, 0x0fb4, 0x0fb5, 0x0fb6, 0x0fb7, - 0x0fb8, 0x0fb9, 0x0fba, 0x0fbb, 0x0fbc, 0x0fbd, 0x0fbe, 0x0fbf, - 0x1f80, 0x1f81, 0x1f82, 0x1f83, 0x1f84, 0x1f85, 0x1f86, 0x1f87, - 0x1f88, 0x1f89, 0x1f8a, 0x1f8b, 0x1f8c, 0x1f8d, 0x1f8e, 0x1f8f, - 0x1f90, 0x1f91, 0x1f92, 0x1f93, 0x1f94, 0x1f95, 0x1f96, 0x1f97, - 0x1f98, 0x1f99, 0x1f9a, 0x1f9b, 0x1f9c, 0x1f9d, 0x1f9e, 0x1f9f, - 0x1fa0, 0x1fa1, 0x1fa2, 0x1fa3, 0x1fa4, 0x1fa5, 0x1fa6, 0x1fa7, - 0x1fa8, 0x1fa9, 0x1faa, 0x1fab, 0x1fac, 0x1fad, 0x1fae, 0x1faf, - 0x1fb0, 0x1fb1, 0x1fb2, 0x1fb3, 0x1fb4, 0x1fb5, 0x1fb6, 0x1fb7, - 0x1fb8, 0x1fb9, 0x1fba, 0x1fbb, 0x1fbc, 0x1fbd, 0x1fbe, 0x1fbf, - 0x7f00, 0x7f01, 0x7f02, 0x7f03, 0x7f04, 0x7f05, 0x7f06, 0x7f07, - 0x7f08, 0x7f09, 0x7f0a, 0x7f0b, 0x7f0c, 0x7f0d, 0x7f0e, 0x7f0f, - 0x7f10, 0x7f11, 0x7f12, 0x7f13, 0x7f14, 0x7f15, 0x7f16, 0x7f17, - 0x7f18, 0x7f19, 0x7f1a, 0x7f1b, 0x7f1c, 0x7f1d, 0x7f1e, 0x7f1f, - 0x7f20, 0x7f21, 0x7f22, 0x7f23, 0x7f24, 0x7f25, 0x7f26, 0x7f27, - 0x7f28, 0x7f29, 0x7f2a, 0x7f2b, 0x7f2c, 0x7f2d, 0x7f2e, 0x7f2f, - 0x7f30, 0x7f31, 0x7f32, 0x7f33, 0x7f34, 0x7f35, 0x7f36, 0x7f37, - 0x7f38, 0x7f39, 0x7f3a, 0x7f3b, 0x7f3c, 0x7f3d, 0x7f3e, 0x7f3f, - 0x7f40, 0x7f41, 0x7f42, 0x7f43, 0x7f44, 0x7f45, 0x7f46, 0x7f47, - 0x7f48, 0x7f49, 0x7f4a, 0x7f4b, 0x7f4c, 0x7f4d, 0x7f4e, 0x7f4f, - 0x7f50, 0x7f51, 0x7f52, 0x7f53, 0x7f54, 0x7f55, 0x7f56, 0x7f57, - 0x7f58, 0x7f59, 0x7f5a, 0x7f5b, 0x7f5c, 0x7f5d, 0x7f5e, 0x7f5f, - 0x7f60, 0x7f61, 0x7f62, 0x7f63, 0x7f64, 0x7f65, 0x7f66, 0x7f67, - 0x7f68, 0x7f69, 0x7f6a, 0x7f6b, 0x7f6c, 0x7f6d, 0x7f6e, 0x7f6f, - 0x7f70, 0x7f71, 0x7f72, 0x7f73, 0x7f74, 0x7f75, 0x7f76, 0x7f77, - 0x7f78, 0x7f79, 0x7f7a, 0x7f7b, 0x7f7c, 0x7f7d, 0x7f7e, 0x7f7f, - 0x7f80, 0x7f81, 0x7f82, 0x7f83, 0x7f84, 0x7f85, 0x7f86, 0x7f87, - 0x7f88, 0x7f89, 0x7f8a, 0x7f8b, 0x7f8c, 0x7f8d, 0x7f8e, 0x7f8f, - 0x7f90, 0x7f91, 0x7f92, 0x7f93, 0x7f94, 0x7f95, 0x7f96, 0x7f97, - 0x7f98, 0x7f99, 0x7f9a, 0x7f9b, 0x7f9c, 0x7f9d, 0x7f9e, 0x7f9f, - 0x7fa0, 0x7fa1, 0x7fa2, 0x7fa3, 0x7fa4, 0x7fa5, 0x7fa6, 0x7fa7, - 0x7fa8, 0x7fa9, 0x7faa, 0x7fab, 0x7fac, 0x7fad, 0x7fae, 0x7faf, - 0x7fb0, 0x7fb1, 0x7fb2, 0x7fb3, 0x7fb4, 0x7fb5, 0x7fb6, 0x7fb7, - 0x7fb8, 0x7fb9, 0x7fba, 0x7fbb, 0x7fbc, 0x7fbd, 0x7fbe, 0x7fbf, - 0x7fc0, 0x7fc1, 0x7fc2, 0x7fc3, 0x7fc4, 0x7fc5, 0x7fc6, 0x7fc7, - 0x7fc8, 0x7fc9, 0x7fca, 0x7fcb, 0x7fcc, 0x7fcd, 0x7fce, 0x7fcf, - 0x7fd0, 0x7fd1, 0x7fd2, 0x7fd3, 0x7fd4, 0x7fd5, 0x7fd6, 0x7fd7, - 0x7fd8, 0x7fd9, 0x7fda, 0x7fdb, 0x7fdc, 0x7fdd, 0x7fde, 0x7fdf, - 0x7fe0, 0x7fe1, 0x7fe2, 0x7fe3, 0x7fe4, 0x7fe5, 0x7fe6, 0x7fe7, - 0x7fe8, 0x7fe9, 0x7fea, 0x7feb, 0x7fec, 0x7fed, 0x7fee, 0x7fef, - 0x7ff0, 0x7ff1, 0x7ff2, 0x7ff3, 0x7ff4, 0x7ff5, 0x7ff6, 0x7ff7, - 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff, - 0x0006, -}; - -static const uint8_t dv_vlc_len[409] = { - 2, 3, 4, 4, 4, 5, 5, 5, - 5, 6, 6, 6, 6, 7, 7, 7, - 7, 7, 7, 7, 7, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 9, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 10, 11, 11, 11, 11, - 11, 11, 11, 11, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, 12, 12, 12, 12, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 13, 13, 13, 13, 13, 13, 13, 13, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 15, 15, 15, 15, 15, 15, 15, 15, - 4, -}; - -static const uint8_t dv_vlc_run[409] = { - 0, 0, 1, 0, 0, 2, 1, 0, - 0, 3, 4, 0, 0, 5, 6, 2, - 1, 1, 0, 0, 0, 7, 8, 9, - 10, 3, 4, 2, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 11, 12, 13, - 14, 5, 6, 3, 4, 2, 2, 1, - 0, 0, 0, 0, 0, 5, 3, 3, - 2, 1, 1, 1, 0, 1, 6, 4, - 3, 1, 1, 1, 2, 3, 4, 5, - 7, 8, 9, 10, 7, 8, 4, 3, - 2, 2, 2, 2, 2, 1, 1, 1, - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -127, -}; - -static const uint8_t dv_vlc_level[409] = { - 1, 2, 1, 3, 4, 1, 2, 5, - 6, 1, 1, 7, 8, 1, 1, 2, - 3, 4, 9, 10, 11, 1, 1, 1, - 1, 2, 2, 3, 5, 6, 7, 12, - 13, 14, 15, 16, 17, 1, 1, 1, - 1, 2, 2, 3, 3, 4, 5, 8, - 18, 19, 20, 21, 22, 3, 4, 5, - 6, 9, 10, 11, 0, 0, 3, 4, - 6, 12, 13, 14, 0, 0, 0, 0, - 2, 2, 2, 2, 3, 3, 5, 7, - 7, 8, 9, 10, 11, 15, 16, 17, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, - 72, 73, 74, 75, 76, 77, 78, 79, - 80, 81, 82, 83, 84, 85, 86, 87, - 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 108, 109, 110, 111, - 112, 113, 114, 115, 116, 117, 118, 119, - 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 141, 142, 143, - 144, 145, 146, 147, 148, 149, 150, 151, - 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, - 168, 169, 170, 171, 172, 173, 174, 175, - 176, 177, 178, 179, 180, 181, 182, 183, - 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, - 200, 201, 202, 203, 204, 205, 206, 207, - 208, 209, 210, 211, 212, 213, 214, 215, - 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, - 232, 233, 234, 235, 236, 237, 238, 239, - 240, 241, 242, 243, 244, 245, 246, 247, - 248, 249, 250, 251, 252, 253, 254, 255, - 0, -}; - -/* unquant tables (not used directly) */ -static const uint8_t dv_88_areas[64] = { - 0,0,0,1,1,1,2,2, - 0,0,1,1,1,2,2,2, - 0,1,1,1,2,2,2,3, - 1,1,1,2,2,2,3,3, - 1,1,2,2,2,3,3,3, - 1,2,2,2,3,3,3,3, - 2,2,2,3,3,3,3,3, - 2,2,3,3,3,3,3,3, -}; - -static const uint8_t dv_248_areas[64] = { - 0,0,1,1,1,2,2,3, - 0,0,1,1,2,2,2,3, - 0,1,1,2,2,2,3,3, - 0,1,1,2,2,2,3,3, - 1,1,2,2,2,3,3,3, - 1,1,2,2,2,3,3,3, - 1,2,2,2,3,3,3,3, - 1,2,2,3,3,3,3,3, -}; - -static const uint8_t dv_quant_shifts[22][4] = { - { 3,3,4,4 }, - { 3,3,4,4 }, - { 2,3,3,4 }, - { 2,3,3,4 }, - { 2,2,3,3 }, - { 2,2,3,3 }, - { 1,2,2,3 }, - { 1,2,2,3 }, - { 1,1,2,2 }, - { 1,1,2,2 }, - { 0,1,1,2 }, - { 0,1,1,2 }, - { 0,0,1,1 }, - { 0,0,1,1 }, - { 0,0,0,1 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, - { 0,0,0,0 }, -}; - -static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 }; - -/* NOTE: I prefer hardcoding the positionning of dv blocks, it is - simpler :-) */ - -static const uint16_t dv_place_420[1620] = { - 0x0c24, 0x2412, 0x3036, 0x0000, 0x1848, - 0x0e24, 0x2612, 0x3236, 0x0200, 0x1a48, - 0x1024, 0x2812, 0x3436, 0x0400, 0x1c48, - 0x1026, 0x2814, 0x3438, 0x0402, 0x1c4a, - 0x0e26, 0x2614, 0x3238, 0x0202, 0x1a4a, - 0x0c26, 0x2414, 0x3038, 0x0002, 0x184a, - 0x0c28, 0x2416, 0x303a, 0x0004, 0x184c, - 0x0e28, 0x2616, 0x323a, 0x0204, 0x1a4c, - 0x1028, 0x2816, 0x343a, 0x0404, 0x1c4c, - 0x102a, 0x2818, 0x343c, 0x0406, 0x1c4e, - 0x0e2a, 0x2618, 0x323c, 0x0206, 0x1a4e, - 0x0c2a, 0x2418, 0x303c, 0x0006, 0x184e, - 0x0c2c, 0x241a, 0x303e, 0x0008, 0x1850, - 0x0e2c, 0x261a, 0x323e, 0x0208, 0x1a50, - 0x102c, 0x281a, 0x343e, 0x0408, 0x1c50, - 0x102e, 0x281c, 0x3440, 0x040a, 0x1c52, - 0x0e2e, 0x261c, 0x3240, 0x020a, 0x1a52, - 0x0c2e, 0x241c, 0x3040, 0x000a, 0x1852, - 0x0c30, 0x241e, 0x3042, 0x000c, 0x1854, - 0x0e30, 0x261e, 0x3242, 0x020c, 0x1a54, - 0x1030, 0x281e, 0x3442, 0x040c, 0x1c54, - 0x1032, 0x2820, 0x3444, 0x040e, 0x1c56, - 0x0e32, 0x2620, 0x3244, 0x020e, 0x1a56, - 0x0c32, 0x2420, 0x3044, 0x000e, 0x1856, - 0x0c34, 0x2422, 0x3046, 0x0010, 0x1858, - 0x0e34, 0x2622, 0x3246, 0x0210, 0x1a58, - 0x1034, 0x2822, 0x3446, 0x0410, 0x1c58, - 0x1224, 0x2a12, 0x3636, 0x0600, 0x1e48, - 0x1424, 0x2c12, 0x3836, 0x0800, 0x2048, - 0x1624, 0x2e12, 0x3a36, 0x0a00, 0x2248, - 0x1626, 0x2e14, 0x3a38, 0x0a02, 0x224a, - 0x1426, 0x2c14, 0x3838, 0x0802, 0x204a, - 0x1226, 0x2a14, 0x3638, 0x0602, 0x1e4a, - 0x1228, 0x2a16, 0x363a, 0x0604, 0x1e4c, - 0x1428, 0x2c16, 0x383a, 0x0804, 0x204c, - 0x1628, 0x2e16, 0x3a3a, 0x0a04, 0x224c, - 0x162a, 0x2e18, 0x3a3c, 0x0a06, 0x224e, - 0x142a, 0x2c18, 0x383c, 0x0806, 0x204e, - 0x122a, 0x2a18, 0x363c, 0x0606, 0x1e4e, - 0x122c, 0x2a1a, 0x363e, 0x0608, 0x1e50, - 0x142c, 0x2c1a, 0x383e, 0x0808, 0x2050, - 0x162c, 0x2e1a, 0x3a3e, 0x0a08, 0x2250, - 0x162e, 0x2e1c, 0x3a40, 0x0a0a, 0x2252, - 0x142e, 0x2c1c, 0x3840, 0x080a, 0x2052, - 0x122e, 0x2a1c, 0x3640, 0x060a, 0x1e52, - 0x1230, 0x2a1e, 0x3642, 0x060c, 0x1e54, - 0x1430, 0x2c1e, 0x3842, 0x080c, 0x2054, - 0x1630, 0x2e1e, 0x3a42, 0x0a0c, 0x2254, - 0x1632, 0x2e20, 0x3a44, 0x0a0e, 0x2256, - 0x1432, 0x2c20, 0x3844, 0x080e, 0x2056, - 0x1232, 0x2a20, 0x3644, 0x060e, 0x1e56, - 0x1234, 0x2a22, 0x3646, 0x0610, 0x1e58, - 0x1434, 0x2c22, 0x3846, 0x0810, 0x2058, - 0x1634, 0x2e22, 0x3a46, 0x0a10, 0x2258, - 0x1824, 0x3012, 0x3c36, 0x0c00, 0x2448, - 0x1a24, 0x3212, 0x3e36, 0x0e00, 0x2648, - 0x1c24, 0x3412, 0x4036, 0x1000, 0x2848, - 0x1c26, 0x3414, 0x4038, 0x1002, 0x284a, - 0x1a26, 0x3214, 0x3e38, 0x0e02, 0x264a, - 0x1826, 0x3014, 0x3c38, 0x0c02, 0x244a, - 0x1828, 0x3016, 0x3c3a, 0x0c04, 0x244c, - 0x1a28, 0x3216, 0x3e3a, 0x0e04, 0x264c, - 0x1c28, 0x3416, 0x403a, 0x1004, 0x284c, - 0x1c2a, 0x3418, 0x403c, 0x1006, 0x284e, - 0x1a2a, 0x3218, 0x3e3c, 0x0e06, 0x264e, - 0x182a, 0x3018, 0x3c3c, 0x0c06, 0x244e, - 0x182c, 0x301a, 0x3c3e, 0x0c08, 0x2450, - 0x1a2c, 0x321a, 0x3e3e, 0x0e08, 0x2650, - 0x1c2c, 0x341a, 0x403e, 0x1008, 0x2850, - 0x1c2e, 0x341c, 0x4040, 0x100a, 0x2852, - 0x1a2e, 0x321c, 0x3e40, 0x0e0a, 0x2652, - 0x182e, 0x301c, 0x3c40, 0x0c0a, 0x2452, - 0x1830, 0x301e, 0x3c42, 0x0c0c, 0x2454, - 0x1a30, 0x321e, 0x3e42, 0x0e0c, 0x2654, - 0x1c30, 0x341e, 0x4042, 0x100c, 0x2854, - 0x1c32, 0x3420, 0x4044, 0x100e, 0x2856, - 0x1a32, 0x3220, 0x3e44, 0x0e0e, 0x2656, - 0x1832, 0x3020, 0x3c44, 0x0c0e, 0x2456, - 0x1834, 0x3022, 0x3c46, 0x0c10, 0x2458, - 0x1a34, 0x3222, 0x3e46, 0x0e10, 0x2658, - 0x1c34, 0x3422, 0x4046, 0x1010, 0x2858, - 0x1e24, 0x3612, 0x4236, 0x1200, 0x2a48, - 0x2024, 0x3812, 0x4436, 0x1400, 0x2c48, - 0x2224, 0x3a12, 0x4636, 0x1600, 0x2e48, - 0x2226, 0x3a14, 0x4638, 0x1602, 0x2e4a, - 0x2026, 0x3814, 0x4438, 0x1402, 0x2c4a, - 0x1e26, 0x3614, 0x4238, 0x1202, 0x2a4a, - 0x1e28, 0x3616, 0x423a, 0x1204, 0x2a4c, - 0x2028, 0x3816, 0x443a, 0x1404, 0x2c4c, - 0x2228, 0x3a16, 0x463a, 0x1604, 0x2e4c, - 0x222a, 0x3a18, 0x463c, 0x1606, 0x2e4e, - 0x202a, 0x3818, 0x443c, 0x1406, 0x2c4e, - 0x1e2a, 0x3618, 0x423c, 0x1206, 0x2a4e, - 0x1e2c, 0x361a, 0x423e, 0x1208, 0x2a50, - 0x202c, 0x381a, 0x443e, 0x1408, 0x2c50, - 0x222c, 0x3a1a, 0x463e, 0x1608, 0x2e50, - 0x222e, 0x3a1c, 0x4640, 0x160a, 0x2e52, - 0x202e, 0x381c, 0x4440, 0x140a, 0x2c52, - 0x1e2e, 0x361c, 0x4240, 0x120a, 0x2a52, - 0x1e30, 0x361e, 0x4242, 0x120c, 0x2a54, - 0x2030, 0x381e, 0x4442, 0x140c, 0x2c54, - 0x2230, 0x3a1e, 0x4642, 0x160c, 0x2e54, - 0x2232, 0x3a20, 0x4644, 0x160e, 0x2e56, - 0x2032, 0x3820, 0x4444, 0x140e, 0x2c56, - 0x1e32, 0x3620, 0x4244, 0x120e, 0x2a56, - 0x1e34, 0x3622, 0x4246, 0x1210, 0x2a58, - 0x2034, 0x3822, 0x4446, 0x1410, 0x2c58, - 0x2234, 0x3a22, 0x4646, 0x1610, 0x2e58, - 0x2424, 0x3c12, 0x0036, 0x1800, 0x3048, - 0x2624, 0x3e12, 0x0236, 0x1a00, 0x3248, - 0x2824, 0x4012, 0x0436, 0x1c00, 0x3448, - 0x2826, 0x4014, 0x0438, 0x1c02, 0x344a, - 0x2626, 0x3e14, 0x0238, 0x1a02, 0x324a, - 0x2426, 0x3c14, 0x0038, 0x1802, 0x304a, - 0x2428, 0x3c16, 0x003a, 0x1804, 0x304c, - 0x2628, 0x3e16, 0x023a, 0x1a04, 0x324c, - 0x2828, 0x4016, 0x043a, 0x1c04, 0x344c, - 0x282a, 0x4018, 0x043c, 0x1c06, 0x344e, - 0x262a, 0x3e18, 0x023c, 0x1a06, 0x324e, - 0x242a, 0x3c18, 0x003c, 0x1806, 0x304e, - 0x242c, 0x3c1a, 0x003e, 0x1808, 0x3050, - 0x262c, 0x3e1a, 0x023e, 0x1a08, 0x3250, - 0x282c, 0x401a, 0x043e, 0x1c08, 0x3450, - 0x282e, 0x401c, 0x0440, 0x1c0a, 0x3452, - 0x262e, 0x3e1c, 0x0240, 0x1a0a, 0x3252, - 0x242e, 0x3c1c, 0x0040, 0x180a, 0x3052, - 0x2430, 0x3c1e, 0x0042, 0x180c, 0x3054, - 0x2630, 0x3e1e, 0x0242, 0x1a0c, 0x3254, - 0x2830, 0x401e, 0x0442, 0x1c0c, 0x3454, - 0x2832, 0x4020, 0x0444, 0x1c0e, 0x3456, - 0x2632, 0x3e20, 0x0244, 0x1a0e, 0x3256, - 0x2432, 0x3c20, 0x0044, 0x180e, 0x3056, - 0x2434, 0x3c22, 0x0046, 0x1810, 0x3058, - 0x2634, 0x3e22, 0x0246, 0x1a10, 0x3258, - 0x2834, 0x4022, 0x0446, 0x1c10, 0x3458, - 0x2a24, 0x4212, 0x0636, 0x1e00, 0x3648, - 0x2c24, 0x4412, 0x0836, 0x2000, 0x3848, - 0x2e24, 0x4612, 0x0a36, 0x2200, 0x3a48, - 0x2e26, 0x4614, 0x0a38, 0x2202, 0x3a4a, - 0x2c26, 0x4414, 0x0838, 0x2002, 0x384a, - 0x2a26, 0x4214, 0x0638, 0x1e02, 0x364a, - 0x2a28, 0x4216, 0x063a, 0x1e04, 0x364c, - 0x2c28, 0x4416, 0x083a, 0x2004, 0x384c, - 0x2e28, 0x4616, 0x0a3a, 0x2204, 0x3a4c, - 0x2e2a, 0x4618, 0x0a3c, 0x2206, 0x3a4e, - 0x2c2a, 0x4418, 0x083c, 0x2006, 0x384e, - 0x2a2a, 0x4218, 0x063c, 0x1e06, 0x364e, - 0x2a2c, 0x421a, 0x063e, 0x1e08, 0x3650, - 0x2c2c, 0x441a, 0x083e, 0x2008, 0x3850, - 0x2e2c, 0x461a, 0x0a3e, 0x2208, 0x3a50, - 0x2e2e, 0x461c, 0x0a40, 0x220a, 0x3a52, - 0x2c2e, 0x441c, 0x0840, 0x200a, 0x3852, - 0x2a2e, 0x421c, 0x0640, 0x1e0a, 0x3652, - 0x2a30, 0x421e, 0x0642, 0x1e0c, 0x3654, - 0x2c30, 0x441e, 0x0842, 0x200c, 0x3854, - 0x2e30, 0x461e, 0x0a42, 0x220c, 0x3a54, - 0x2e32, 0x4620, 0x0a44, 0x220e, 0x3a56, - 0x2c32, 0x4420, 0x0844, 0x200e, 0x3856, - 0x2a32, 0x4220, 0x0644, 0x1e0e, 0x3656, - 0x2a34, 0x4222, 0x0646, 0x1e10, 0x3658, - 0x2c34, 0x4422, 0x0846, 0x2010, 0x3858, - 0x2e34, 0x4622, 0x0a46, 0x2210, 0x3a58, - 0x3024, 0x0012, 0x0c36, 0x2400, 0x3c48, - 0x3224, 0x0212, 0x0e36, 0x2600, 0x3e48, - 0x3424, 0x0412, 0x1036, 0x2800, 0x4048, - 0x3426, 0x0414, 0x1038, 0x2802, 0x404a, - 0x3226, 0x0214, 0x0e38, 0x2602, 0x3e4a, - 0x3026, 0x0014, 0x0c38, 0x2402, 0x3c4a, - 0x3028, 0x0016, 0x0c3a, 0x2404, 0x3c4c, - 0x3228, 0x0216, 0x0e3a, 0x2604, 0x3e4c, - 0x3428, 0x0416, 0x103a, 0x2804, 0x404c, - 0x342a, 0x0418, 0x103c, 0x2806, 0x404e, - 0x322a, 0x0218, 0x0e3c, 0x2606, 0x3e4e, - 0x302a, 0x0018, 0x0c3c, 0x2406, 0x3c4e, - 0x302c, 0x001a, 0x0c3e, 0x2408, 0x3c50, - 0x322c, 0x021a, 0x0e3e, 0x2608, 0x3e50, - 0x342c, 0x041a, 0x103e, 0x2808, 0x4050, - 0x342e, 0x041c, 0x1040, 0x280a, 0x4052, - 0x322e, 0x021c, 0x0e40, 0x260a, 0x3e52, - 0x302e, 0x001c, 0x0c40, 0x240a, 0x3c52, - 0x3030, 0x001e, 0x0c42, 0x240c, 0x3c54, - 0x3230, 0x021e, 0x0e42, 0x260c, 0x3e54, - 0x3430, 0x041e, 0x1042, 0x280c, 0x4054, - 0x3432, 0x0420, 0x1044, 0x280e, 0x4056, - 0x3232, 0x0220, 0x0e44, 0x260e, 0x3e56, - 0x3032, 0x0020, 0x0c44, 0x240e, 0x3c56, - 0x3034, 0x0022, 0x0c46, 0x2410, 0x3c58, - 0x3234, 0x0222, 0x0e46, 0x2610, 0x3e58, - 0x3434, 0x0422, 0x1046, 0x2810, 0x4058, - 0x3624, 0x0612, 0x1236, 0x2a00, 0x4248, - 0x3824, 0x0812, 0x1436, 0x2c00, 0x4448, - 0x3a24, 0x0a12, 0x1636, 0x2e00, 0x4648, - 0x3a26, 0x0a14, 0x1638, 0x2e02, 0x464a, - 0x3826, 0x0814, 0x1438, 0x2c02, 0x444a, - 0x3626, 0x0614, 0x1238, 0x2a02, 0x424a, - 0x3628, 0x0616, 0x123a, 0x2a04, 0x424c, - 0x3828, 0x0816, 0x143a, 0x2c04, 0x444c, - 0x3a28, 0x0a16, 0x163a, 0x2e04, 0x464c, - 0x3a2a, 0x0a18, 0x163c, 0x2e06, 0x464e, - 0x382a, 0x0818, 0x143c, 0x2c06, 0x444e, - 0x362a, 0x0618, 0x123c, 0x2a06, 0x424e, - 0x362c, 0x061a, 0x123e, 0x2a08, 0x4250, - 0x382c, 0x081a, 0x143e, 0x2c08, 0x4450, - 0x3a2c, 0x0a1a, 0x163e, 0x2e08, 0x4650, - 0x3a2e, 0x0a1c, 0x1640, 0x2e0a, 0x4652, - 0x382e, 0x081c, 0x1440, 0x2c0a, 0x4452, - 0x362e, 0x061c, 0x1240, 0x2a0a, 0x4252, - 0x3630, 0x061e, 0x1242, 0x2a0c, 0x4254, - 0x3830, 0x081e, 0x1442, 0x2c0c, 0x4454, - 0x3a30, 0x0a1e, 0x1642, 0x2e0c, 0x4654, - 0x3a32, 0x0a20, 0x1644, 0x2e0e, 0x4656, - 0x3832, 0x0820, 0x1444, 0x2c0e, 0x4456, - 0x3632, 0x0620, 0x1244, 0x2a0e, 0x4256, - 0x3634, 0x0622, 0x1246, 0x2a10, 0x4258, - 0x3834, 0x0822, 0x1446, 0x2c10, 0x4458, - 0x3a34, 0x0a22, 0x1646, 0x2e10, 0x4658, - 0x3c24, 0x0c12, 0x1836, 0x3000, 0x0048, - 0x3e24, 0x0e12, 0x1a36, 0x3200, 0x0248, - 0x4024, 0x1012, 0x1c36, 0x3400, 0x0448, - 0x4026, 0x1014, 0x1c38, 0x3402, 0x044a, - 0x3e26, 0x0e14, 0x1a38, 0x3202, 0x024a, - 0x3c26, 0x0c14, 0x1838, 0x3002, 0x004a, - 0x3c28, 0x0c16, 0x183a, 0x3004, 0x004c, - 0x3e28, 0x0e16, 0x1a3a, 0x3204, 0x024c, - 0x4028, 0x1016, 0x1c3a, 0x3404, 0x044c, - 0x402a, 0x1018, 0x1c3c, 0x3406, 0x044e, - 0x3e2a, 0x0e18, 0x1a3c, 0x3206, 0x024e, - 0x3c2a, 0x0c18, 0x183c, 0x3006, 0x004e, - 0x3c2c, 0x0c1a, 0x183e, 0x3008, 0x0050, - 0x3e2c, 0x0e1a, 0x1a3e, 0x3208, 0x0250, - 0x402c, 0x101a, 0x1c3e, 0x3408, 0x0450, - 0x402e, 0x101c, 0x1c40, 0x340a, 0x0452, - 0x3e2e, 0x0e1c, 0x1a40, 0x320a, 0x0252, - 0x3c2e, 0x0c1c, 0x1840, 0x300a, 0x0052, - 0x3c30, 0x0c1e, 0x1842, 0x300c, 0x0054, - 0x3e30, 0x0e1e, 0x1a42, 0x320c, 0x0254, - 0x4030, 0x101e, 0x1c42, 0x340c, 0x0454, - 0x4032, 0x1020, 0x1c44, 0x340e, 0x0456, - 0x3e32, 0x0e20, 0x1a44, 0x320e, 0x0256, - 0x3c32, 0x0c20, 0x1844, 0x300e, 0x0056, - 0x3c34, 0x0c22, 0x1846, 0x3010, 0x0058, - 0x3e34, 0x0e22, 0x1a46, 0x3210, 0x0258, - 0x4034, 0x1022, 0x1c46, 0x3410, 0x0458, - 0x4224, 0x1212, 0x1e36, 0x3600, 0x0648, - 0x4424, 0x1412, 0x2036, 0x3800, 0x0848, - 0x4624, 0x1612, 0x2236, 0x3a00, 0x0a48, - 0x4626, 0x1614, 0x2238, 0x3a02, 0x0a4a, - 0x4426, 0x1414, 0x2038, 0x3802, 0x084a, - 0x4226, 0x1214, 0x1e38, 0x3602, 0x064a, - 0x4228, 0x1216, 0x1e3a, 0x3604, 0x064c, - 0x4428, 0x1416, 0x203a, 0x3804, 0x084c, - 0x4628, 0x1616, 0x223a, 0x3a04, 0x0a4c, - 0x462a, 0x1618, 0x223c, 0x3a06, 0x0a4e, - 0x442a, 0x1418, 0x203c, 0x3806, 0x084e, - 0x422a, 0x1218, 0x1e3c, 0x3606, 0x064e, - 0x422c, 0x121a, 0x1e3e, 0x3608, 0x0650, - 0x442c, 0x141a, 0x203e, 0x3808, 0x0850, - 0x462c, 0x161a, 0x223e, 0x3a08, 0x0a50, - 0x462e, 0x161c, 0x2240, 0x3a0a, 0x0a52, - 0x442e, 0x141c, 0x2040, 0x380a, 0x0852, - 0x422e, 0x121c, 0x1e40, 0x360a, 0x0652, - 0x4230, 0x121e, 0x1e42, 0x360c, 0x0654, - 0x4430, 0x141e, 0x2042, 0x380c, 0x0854, - 0x4630, 0x161e, 0x2242, 0x3a0c, 0x0a54, - 0x4632, 0x1620, 0x2244, 0x3a0e, 0x0a56, - 0x4432, 0x1420, 0x2044, 0x380e, 0x0856, - 0x4232, 0x1220, 0x1e44, 0x360e, 0x0656, - 0x4234, 0x1222, 0x1e46, 0x3610, 0x0658, - 0x4434, 0x1422, 0x2046, 0x3810, 0x0858, - 0x4634, 0x1622, 0x2246, 0x3a10, 0x0a58, - 0x0024, 0x1812, 0x2436, 0x3c00, 0x0c48, - 0x0224, 0x1a12, 0x2636, 0x3e00, 0x0e48, - 0x0424, 0x1c12, 0x2836, 0x4000, 0x1048, - 0x0426, 0x1c14, 0x2838, 0x4002, 0x104a, - 0x0226, 0x1a14, 0x2638, 0x3e02, 0x0e4a, - 0x0026, 0x1814, 0x2438, 0x3c02, 0x0c4a, - 0x0028, 0x1816, 0x243a, 0x3c04, 0x0c4c, - 0x0228, 0x1a16, 0x263a, 0x3e04, 0x0e4c, - 0x0428, 0x1c16, 0x283a, 0x4004, 0x104c, - 0x042a, 0x1c18, 0x283c, 0x4006, 0x104e, - 0x022a, 0x1a18, 0x263c, 0x3e06, 0x0e4e, - 0x002a, 0x1818, 0x243c, 0x3c06, 0x0c4e, - 0x002c, 0x181a, 0x243e, 0x3c08, 0x0c50, - 0x022c, 0x1a1a, 0x263e, 0x3e08, 0x0e50, - 0x042c, 0x1c1a, 0x283e, 0x4008, 0x1050, - 0x042e, 0x1c1c, 0x2840, 0x400a, 0x1052, - 0x022e, 0x1a1c, 0x2640, 0x3e0a, 0x0e52, - 0x002e, 0x181c, 0x2440, 0x3c0a, 0x0c52, - 0x0030, 0x181e, 0x2442, 0x3c0c, 0x0c54, - 0x0230, 0x1a1e, 0x2642, 0x3e0c, 0x0e54, - 0x0430, 0x1c1e, 0x2842, 0x400c, 0x1054, - 0x0432, 0x1c20, 0x2844, 0x400e, 0x1056, - 0x0232, 0x1a20, 0x2644, 0x3e0e, 0x0e56, - 0x0032, 0x1820, 0x2444, 0x3c0e, 0x0c56, - 0x0034, 0x1822, 0x2446, 0x3c10, 0x0c58, - 0x0234, 0x1a22, 0x2646, 0x3e10, 0x0e58, - 0x0434, 0x1c22, 0x2846, 0x4010, 0x1058, - 0x0624, 0x1e12, 0x2a36, 0x4200, 0x1248, - 0x0824, 0x2012, 0x2c36, 0x4400, 0x1448, - 0x0a24, 0x2212, 0x2e36, 0x4600, 0x1648, - 0x0a26, 0x2214, 0x2e38, 0x4602, 0x164a, - 0x0826, 0x2014, 0x2c38, 0x4402, 0x144a, - 0x0626, 0x1e14, 0x2a38, 0x4202, 0x124a, - 0x0628, 0x1e16, 0x2a3a, 0x4204, 0x124c, - 0x0828, 0x2016, 0x2c3a, 0x4404, 0x144c, - 0x0a28, 0x2216, 0x2e3a, 0x4604, 0x164c, - 0x0a2a, 0x2218, 0x2e3c, 0x4606, 0x164e, - 0x082a, 0x2018, 0x2c3c, 0x4406, 0x144e, - 0x062a, 0x1e18, 0x2a3c, 0x4206, 0x124e, - 0x062c, 0x1e1a, 0x2a3e, 0x4208, 0x1250, - 0x082c, 0x201a, 0x2c3e, 0x4408, 0x1450, - 0x0a2c, 0x221a, 0x2e3e, 0x4608, 0x1650, - 0x0a2e, 0x221c, 0x2e40, 0x460a, 0x1652, - 0x082e, 0x201c, 0x2c40, 0x440a, 0x1452, - 0x062e, 0x1e1c, 0x2a40, 0x420a, 0x1252, - 0x0630, 0x1e1e, 0x2a42, 0x420c, 0x1254, - 0x0830, 0x201e, 0x2c42, 0x440c, 0x1454, - 0x0a30, 0x221e, 0x2e42, 0x460c, 0x1654, - 0x0a32, 0x2220, 0x2e44, 0x460e, 0x1656, - 0x0832, 0x2020, 0x2c44, 0x440e, 0x1456, - 0x0632, 0x1e20, 0x2a44, 0x420e, 0x1256, - 0x0634, 0x1e22, 0x2a46, 0x4210, 0x1258, - 0x0834, 0x2022, 0x2c46, 0x4410, 0x1458, - 0x0a34, 0x2222, 0x2e46, 0x4610, 0x1658, -}; - -static const uint16_t dv_place_411P[1620] = { - 0x0c24, 0x2710, 0x3334, 0x0000, 0x1848, - 0x0d24, 0x2810, 0x3434, 0x0100, 0x1948, - 0x0e24, 0x2910, 0x3534, 0x0200, 0x1a48, - 0x0f24, 0x2914, 0x3538, 0x0300, 0x1b48, - 0x1024, 0x2814, 0x3438, 0x0400, 0x1c48, - 0x1124, 0x2714, 0x3338, 0x0500, 0x1d48, - 0x1128, 0x2614, 0x3238, 0x0504, 0x1d4c, - 0x1028, 0x2514, 0x3138, 0x0404, 0x1c4c, - 0x0f28, 0x2414, 0x3038, 0x0304, 0x1b4c, - 0x0e28, 0x2418, 0x303c, 0x0204, 0x1a4c, - 0x0d28, 0x2518, 0x313c, 0x0104, 0x194c, - 0x0c28, 0x2618, 0x323c, 0x0004, 0x184c, - 0x0c2c, 0x2718, 0x333c, 0x0008, 0x1850, - 0x0d2c, 0x2818, 0x343c, 0x0108, 0x1950, - 0x0e2c, 0x2918, 0x353c, 0x0208, 0x1a50, - 0x0f2c, 0x291c, 0x3540, 0x0308, 0x1b50, - 0x102c, 0x281c, 0x3440, 0x0408, 0x1c50, - 0x112c, 0x271c, 0x3340, 0x0508, 0x1d50, - 0x1130, 0x261c, 0x3240, 0x050c, 0x1d54, - 0x1030, 0x251c, 0x3140, 0x040c, 0x1c54, - 0x0f30, 0x241c, 0x3040, 0x030c, 0x1b54, - 0x0e30, 0x2420, 0x3044, 0x020c, 0x1a54, - 0x0d30, 0x2520, 0x3144, 0x010c, 0x1954, - 0x0c30, 0x2620, 0x3244, 0x000c, 0x1854, - 0x0c34, 0x2720, 0x3344, 0x0010, 0x1858, - 0x0d34, 0x2820, 0x3444, 0x0110, 0x1a58, - 0x0e34, 0x2920, 0x3544, 0x0210, 0x1c58, - 0x1224, 0x2d10, 0x3934, 0x0600, 0x1e48, - 0x1324, 0x2e10, 0x3a34, 0x0700, 0x1f48, - 0x1424, 0x2f10, 0x3b34, 0x0800, 0x2048, - 0x1524, 0x2f14, 0x3b38, 0x0900, 0x2148, - 0x1624, 0x2e14, 0x3a38, 0x0a00, 0x2248, - 0x1724, 0x2d14, 0x3938, 0x0b00, 0x2348, - 0x1728, 0x2c14, 0x3838, 0x0b04, 0x234c, - 0x1628, 0x2b14, 0x3738, 0x0a04, 0x224c, - 0x1528, 0x2a14, 0x3638, 0x0904, 0x214c, - 0x1428, 0x2a18, 0x363c, 0x0804, 0x204c, - 0x1328, 0x2b18, 0x373c, 0x0704, 0x1f4c, - 0x1228, 0x2c18, 0x383c, 0x0604, 0x1e4c, - 0x122c, 0x2d18, 0x393c, 0x0608, 0x1e50, - 0x132c, 0x2e18, 0x3a3c, 0x0708, 0x1f50, - 0x142c, 0x2f18, 0x3b3c, 0x0808, 0x2050, - 0x152c, 0x2f1c, 0x3b40, 0x0908, 0x2150, - 0x162c, 0x2e1c, 0x3a40, 0x0a08, 0x2250, - 0x172c, 0x2d1c, 0x3940, 0x0b08, 0x2350, - 0x1730, 0x2c1c, 0x3840, 0x0b0c, 0x2354, - 0x1630, 0x2b1c, 0x3740, 0x0a0c, 0x2254, - 0x1530, 0x2a1c, 0x3640, 0x090c, 0x2154, - 0x1430, 0x2a20, 0x3644, 0x080c, 0x2054, - 0x1330, 0x2b20, 0x3744, 0x070c, 0x1f54, - 0x1230, 0x2c20, 0x3844, 0x060c, 0x1e54, - 0x1234, 0x2d20, 0x3944, 0x0610, 0x1e58, - 0x1334, 0x2e20, 0x3a44, 0x0710, 0x2058, - 0x1434, 0x2f20, 0x3b44, 0x0810, 0x2258, - 0x1824, 0x3310, 0x3f34, 0x0c00, 0x2448, - 0x1924, 0x3410, 0x4034, 0x0d00, 0x2548, - 0x1a24, 0x3510, 0x4134, 0x0e00, 0x2648, - 0x1b24, 0x3514, 0x4138, 0x0f00, 0x2748, - 0x1c24, 0x3414, 0x4038, 0x1000, 0x2848, - 0x1d24, 0x3314, 0x3f38, 0x1100, 0x2948, - 0x1d28, 0x3214, 0x3e38, 0x1104, 0x294c, - 0x1c28, 0x3114, 0x3d38, 0x1004, 0x284c, - 0x1b28, 0x3014, 0x3c38, 0x0f04, 0x274c, - 0x1a28, 0x3018, 0x3c3c, 0x0e04, 0x264c, - 0x1928, 0x3118, 0x3d3c, 0x0d04, 0x254c, - 0x1828, 0x3218, 0x3e3c, 0x0c04, 0x244c, - 0x182c, 0x3318, 0x3f3c, 0x0c08, 0x2450, - 0x192c, 0x3418, 0x403c, 0x0d08, 0x2550, - 0x1a2c, 0x3518, 0x413c, 0x0e08, 0x2650, - 0x1b2c, 0x351c, 0x4140, 0x0f08, 0x2750, - 0x1c2c, 0x341c, 0x4040, 0x1008, 0x2850, - 0x1d2c, 0x331c, 0x3f40, 0x1108, 0x2950, - 0x1d30, 0x321c, 0x3e40, 0x110c, 0x2954, - 0x1c30, 0x311c, 0x3d40, 0x100c, 0x2854, - 0x1b30, 0x301c, 0x3c40, 0x0f0c, 0x2754, - 0x1a30, 0x3020, 0x3c44, 0x0e0c, 0x2654, - 0x1930, 0x3120, 0x3d44, 0x0d0c, 0x2554, - 0x1830, 0x3220, 0x3e44, 0x0c0c, 0x2454, - 0x1834, 0x3320, 0x3f44, 0x0c10, 0x2458, - 0x1934, 0x3420, 0x4044, 0x0d10, 0x2658, - 0x1a34, 0x3520, 0x4144, 0x0e10, 0x2858, - 0x1e24, 0x3910, 0x4534, 0x1200, 0x2a48, - 0x1f24, 0x3a10, 0x4634, 0x1300, 0x2b48, - 0x2024, 0x3b10, 0x4734, 0x1400, 0x2c48, - 0x2124, 0x3b14, 0x4738, 0x1500, 0x2d48, - 0x2224, 0x3a14, 0x4638, 0x1600, 0x2e48, - 0x2324, 0x3914, 0x4538, 0x1700, 0x2f48, - 0x2328, 0x3814, 0x4438, 0x1704, 0x2f4c, - 0x2228, 0x3714, 0x4338, 0x1604, 0x2e4c, - 0x2128, 0x3614, 0x4238, 0x1504, 0x2d4c, - 0x2028, 0x3618, 0x423c, 0x1404, 0x2c4c, - 0x1f28, 0x3718, 0x433c, 0x1304, 0x2b4c, - 0x1e28, 0x3818, 0x443c, 0x1204, 0x2a4c, - 0x1e2c, 0x3918, 0x453c, 0x1208, 0x2a50, - 0x1f2c, 0x3a18, 0x463c, 0x1308, 0x2b50, - 0x202c, 0x3b18, 0x473c, 0x1408, 0x2c50, - 0x212c, 0x3b1c, 0x4740, 0x1508, 0x2d50, - 0x222c, 0x3a1c, 0x4640, 0x1608, 0x2e50, - 0x232c, 0x391c, 0x4540, 0x1708, 0x2f50, - 0x2330, 0x381c, 0x4440, 0x170c, 0x2f54, - 0x2230, 0x371c, 0x4340, 0x160c, 0x2e54, - 0x2130, 0x361c, 0x4240, 0x150c, 0x2d54, - 0x2030, 0x3620, 0x4244, 0x140c, 0x2c54, - 0x1f30, 0x3720, 0x4344, 0x130c, 0x2b54, - 0x1e30, 0x3820, 0x4444, 0x120c, 0x2a54, - 0x1e34, 0x3920, 0x4544, 0x1210, 0x2a58, - 0x1f34, 0x3a20, 0x4644, 0x1310, 0x2c58, - 0x2034, 0x3b20, 0x4744, 0x1410, 0x2e58, - 0x2424, 0x3f10, 0x0334, 0x1800, 0x3048, - 0x2524, 0x4010, 0x0434, 0x1900, 0x3148, - 0x2624, 0x4110, 0x0534, 0x1a00, 0x3248, - 0x2724, 0x4114, 0x0538, 0x1b00, 0x3348, - 0x2824, 0x4014, 0x0438, 0x1c00, 0x3448, - 0x2924, 0x3f14, 0x0338, 0x1d00, 0x3548, - 0x2928, 0x3e14, 0x0238, 0x1d04, 0x354c, - 0x2828, 0x3d14, 0x0138, 0x1c04, 0x344c, - 0x2728, 0x3c14, 0x0038, 0x1b04, 0x334c, - 0x2628, 0x3c18, 0x003c, 0x1a04, 0x324c, - 0x2528, 0x3d18, 0x013c, 0x1904, 0x314c, - 0x2428, 0x3e18, 0x023c, 0x1804, 0x304c, - 0x242c, 0x3f18, 0x033c, 0x1808, 0x3050, - 0x252c, 0x4018, 0x043c, 0x1908, 0x3150, - 0x262c, 0x4118, 0x053c, 0x1a08, 0x3250, - 0x272c, 0x411c, 0x0540, 0x1b08, 0x3350, - 0x282c, 0x401c, 0x0440, 0x1c08, 0x3450, - 0x292c, 0x3f1c, 0x0340, 0x1d08, 0x3550, - 0x2930, 0x3e1c, 0x0240, 0x1d0c, 0x3554, - 0x2830, 0x3d1c, 0x0140, 0x1c0c, 0x3454, - 0x2730, 0x3c1c, 0x0040, 0x1b0c, 0x3354, - 0x2630, 0x3c20, 0x0044, 0x1a0c, 0x3254, - 0x2530, 0x3d20, 0x0144, 0x190c, 0x3154, - 0x2430, 0x3e20, 0x0244, 0x180c, 0x3054, - 0x2434, 0x3f20, 0x0344, 0x1810, 0x3058, - 0x2534, 0x4020, 0x0444, 0x1910, 0x3258, - 0x2634, 0x4120, 0x0544, 0x1a10, 0x3458, - 0x2a24, 0x4510, 0x0934, 0x1e00, 0x3648, - 0x2b24, 0x4610, 0x0a34, 0x1f00, 0x3748, - 0x2c24, 0x4710, 0x0b34, 0x2000, 0x3848, - 0x2d24, 0x4714, 0x0b38, 0x2100, 0x3948, - 0x2e24, 0x4614, 0x0a38, 0x2200, 0x3a48, - 0x2f24, 0x4514, 0x0938, 0x2300, 0x3b48, - 0x2f28, 0x4414, 0x0838, 0x2304, 0x3b4c, - 0x2e28, 0x4314, 0x0738, 0x2204, 0x3a4c, - 0x2d28, 0x4214, 0x0638, 0x2104, 0x394c, - 0x2c28, 0x4218, 0x063c, 0x2004, 0x384c, - 0x2b28, 0x4318, 0x073c, 0x1f04, 0x374c, - 0x2a28, 0x4418, 0x083c, 0x1e04, 0x364c, - 0x2a2c, 0x4518, 0x093c, 0x1e08, 0x3650, - 0x2b2c, 0x4618, 0x0a3c, 0x1f08, 0x3750, - 0x2c2c, 0x4718, 0x0b3c, 0x2008, 0x3850, - 0x2d2c, 0x471c, 0x0b40, 0x2108, 0x3950, - 0x2e2c, 0x461c, 0x0a40, 0x2208, 0x3a50, - 0x2f2c, 0x451c, 0x0940, 0x2308, 0x3b50, - 0x2f30, 0x441c, 0x0840, 0x230c, 0x3b54, - 0x2e30, 0x431c, 0x0740, 0x220c, 0x3a54, - 0x2d30, 0x421c, 0x0640, 0x210c, 0x3954, - 0x2c30, 0x4220, 0x0644, 0x200c, 0x3854, - 0x2b30, 0x4320, 0x0744, 0x1f0c, 0x3754, - 0x2a30, 0x4420, 0x0844, 0x1e0c, 0x3654, - 0x2a34, 0x4520, 0x0944, 0x1e10, 0x3658, - 0x2b34, 0x4620, 0x0a44, 0x1f10, 0x3858, - 0x2c34, 0x4720, 0x0b44, 0x2010, 0x3a58, - 0x3024, 0x0310, 0x0f34, 0x2400, 0x3c48, - 0x3124, 0x0410, 0x1034, 0x2500, 0x3d48, - 0x3224, 0x0510, 0x1134, 0x2600, 0x3e48, - 0x3324, 0x0514, 0x1138, 0x2700, 0x3f48, - 0x3424, 0x0414, 0x1038, 0x2800, 0x4048, - 0x3524, 0x0314, 0x0f38, 0x2900, 0x4148, - 0x3528, 0x0214, 0x0e38, 0x2904, 0x414c, - 0x3428, 0x0114, 0x0d38, 0x2804, 0x404c, - 0x3328, 0x0014, 0x0c38, 0x2704, 0x3f4c, - 0x3228, 0x0018, 0x0c3c, 0x2604, 0x3e4c, - 0x3128, 0x0118, 0x0d3c, 0x2504, 0x3d4c, - 0x3028, 0x0218, 0x0e3c, 0x2404, 0x3c4c, - 0x302c, 0x0318, 0x0f3c, 0x2408, 0x3c50, - 0x312c, 0x0418, 0x103c, 0x2508, 0x3d50, - 0x322c, 0x0518, 0x113c, 0x2608, 0x3e50, - 0x332c, 0x051c, 0x1140, 0x2708, 0x3f50, - 0x342c, 0x041c, 0x1040, 0x2808, 0x4050, - 0x352c, 0x031c, 0x0f40, 0x2908, 0x4150, - 0x3530, 0x021c, 0x0e40, 0x290c, 0x4154, - 0x3430, 0x011c, 0x0d40, 0x280c, 0x4054, - 0x3330, 0x001c, 0x0c40, 0x270c, 0x3f54, - 0x3230, 0x0020, 0x0c44, 0x260c, 0x3e54, - 0x3130, 0x0120, 0x0d44, 0x250c, 0x3d54, - 0x3030, 0x0220, 0x0e44, 0x240c, 0x3c54, - 0x3034, 0x0320, 0x0f44, 0x2410, 0x3c58, - 0x3134, 0x0420, 0x1044, 0x2510, 0x3e58, - 0x3234, 0x0520, 0x1144, 0x2610, 0x4058, - 0x3624, 0x0910, 0x1534, 0x2a00, 0x4248, - 0x3724, 0x0a10, 0x1634, 0x2b00, 0x4348, - 0x3824, 0x0b10, 0x1734, 0x2c00, 0x4448, - 0x3924, 0x0b14, 0x1738, 0x2d00, 0x4548, - 0x3a24, 0x0a14, 0x1638, 0x2e00, 0x4648, - 0x3b24, 0x0914, 0x1538, 0x2f00, 0x4748, - 0x3b28, 0x0814, 0x1438, 0x2f04, 0x474c, - 0x3a28, 0x0714, 0x1338, 0x2e04, 0x464c, - 0x3928, 0x0614, 0x1238, 0x2d04, 0x454c, - 0x3828, 0x0618, 0x123c, 0x2c04, 0x444c, - 0x3728, 0x0718, 0x133c, 0x2b04, 0x434c, - 0x3628, 0x0818, 0x143c, 0x2a04, 0x424c, - 0x362c, 0x0918, 0x153c, 0x2a08, 0x4250, - 0x372c, 0x0a18, 0x163c, 0x2b08, 0x4350, - 0x382c, 0x0b18, 0x173c, 0x2c08, 0x4450, - 0x392c, 0x0b1c, 0x1740, 0x2d08, 0x4550, - 0x3a2c, 0x0a1c, 0x1640, 0x2e08, 0x4650, - 0x3b2c, 0x091c, 0x1540, 0x2f08, 0x4750, - 0x3b30, 0x081c, 0x1440, 0x2f0c, 0x4754, - 0x3a30, 0x071c, 0x1340, 0x2e0c, 0x4654, - 0x3930, 0x061c, 0x1240, 0x2d0c, 0x4554, - 0x3830, 0x0620, 0x1244, 0x2c0c, 0x4454, - 0x3730, 0x0720, 0x1344, 0x2b0c, 0x4354, - 0x3630, 0x0820, 0x1444, 0x2a0c, 0x4254, - 0x3634, 0x0920, 0x1544, 0x2a10, 0x4258, - 0x3734, 0x0a20, 0x1644, 0x2b10, 0x4458, - 0x3834, 0x0b20, 0x1744, 0x2c10, 0x4658, - 0x3c24, 0x0f10, 0x1b34, 0x3000, 0x0048, - 0x3d24, 0x1010, 0x1c34, 0x3100, 0x0148, - 0x3e24, 0x1110, 0x1d34, 0x3200, 0x0248, - 0x3f24, 0x1114, 0x1d38, 0x3300, 0x0348, - 0x4024, 0x1014, 0x1c38, 0x3400, 0x0448, - 0x4124, 0x0f14, 0x1b38, 0x3500, 0x0548, - 0x4128, 0x0e14, 0x1a38, 0x3504, 0x054c, - 0x4028, 0x0d14, 0x1938, 0x3404, 0x044c, - 0x3f28, 0x0c14, 0x1838, 0x3304, 0x034c, - 0x3e28, 0x0c18, 0x183c, 0x3204, 0x024c, - 0x3d28, 0x0d18, 0x193c, 0x3104, 0x014c, - 0x3c28, 0x0e18, 0x1a3c, 0x3004, 0x004c, - 0x3c2c, 0x0f18, 0x1b3c, 0x3008, 0x0050, - 0x3d2c, 0x1018, 0x1c3c, 0x3108, 0x0150, - 0x3e2c, 0x1118, 0x1d3c, 0x3208, 0x0250, - 0x3f2c, 0x111c, 0x1d40, 0x3308, 0x0350, - 0x402c, 0x101c, 0x1c40, 0x3408, 0x0450, - 0x412c, 0x0f1c, 0x1b40, 0x3508, 0x0550, - 0x4130, 0x0e1c, 0x1a40, 0x350c, 0x0554, - 0x4030, 0x0d1c, 0x1940, 0x340c, 0x0454, - 0x3f30, 0x0c1c, 0x1840, 0x330c, 0x0354, - 0x3e30, 0x0c20, 0x1844, 0x320c, 0x0254, - 0x3d30, 0x0d20, 0x1944, 0x310c, 0x0154, - 0x3c30, 0x0e20, 0x1a44, 0x300c, 0x0054, - 0x3c34, 0x0f20, 0x1b44, 0x3010, 0x0058, - 0x3d34, 0x1020, 0x1c44, 0x3110, 0x0258, - 0x3e34, 0x1120, 0x1d44, 0x3210, 0x0458, - 0x4224, 0x1510, 0x2134, 0x3600, 0x0648, - 0x4324, 0x1610, 0x2234, 0x3700, 0x0748, - 0x4424, 0x1710, 0x2334, 0x3800, 0x0848, - 0x4524, 0x1714, 0x2338, 0x3900, 0x0948, - 0x4624, 0x1614, 0x2238, 0x3a00, 0x0a48, - 0x4724, 0x1514, 0x2138, 0x3b00, 0x0b48, - 0x4728, 0x1414, 0x2038, 0x3b04, 0x0b4c, - 0x4628, 0x1314, 0x1f38, 0x3a04, 0x0a4c, - 0x4528, 0x1214, 0x1e38, 0x3904, 0x094c, - 0x4428, 0x1218, 0x1e3c, 0x3804, 0x084c, - 0x4328, 0x1318, 0x1f3c, 0x3704, 0x074c, - 0x4228, 0x1418, 0x203c, 0x3604, 0x064c, - 0x422c, 0x1518, 0x213c, 0x3608, 0x0650, - 0x432c, 0x1618, 0x223c, 0x3708, 0x0750, - 0x442c, 0x1718, 0x233c, 0x3808, 0x0850, - 0x452c, 0x171c, 0x2340, 0x3908, 0x0950, - 0x462c, 0x161c, 0x2240, 0x3a08, 0x0a50, - 0x472c, 0x151c, 0x2140, 0x3b08, 0x0b50, - 0x4730, 0x141c, 0x2040, 0x3b0c, 0x0b54, - 0x4630, 0x131c, 0x1f40, 0x3a0c, 0x0a54, - 0x4530, 0x121c, 0x1e40, 0x390c, 0x0954, - 0x4430, 0x1220, 0x1e44, 0x380c, 0x0854, - 0x4330, 0x1320, 0x1f44, 0x370c, 0x0754, - 0x4230, 0x1420, 0x2044, 0x360c, 0x0654, - 0x4234, 0x1520, 0x2144, 0x3610, 0x0658, - 0x4334, 0x1620, 0x2244, 0x3710, 0x0858, - 0x4434, 0x1720, 0x2344, 0x3810, 0x0a58, - 0x0024, 0x1b10, 0x2734, 0x3c00, 0x0c48, - 0x0124, 0x1c10, 0x2834, 0x3d00, 0x0d48, - 0x0224, 0x1d10, 0x2934, 0x3e00, 0x0e48, - 0x0324, 0x1d14, 0x2938, 0x3f00, 0x0f48, - 0x0424, 0x1c14, 0x2838, 0x4000, 0x1048, - 0x0524, 0x1b14, 0x2738, 0x4100, 0x1148, - 0x0528, 0x1a14, 0x2638, 0x4104, 0x114c, - 0x0428, 0x1914, 0x2538, 0x4004, 0x104c, - 0x0328, 0x1814, 0x2438, 0x3f04, 0x0f4c, - 0x0228, 0x1818, 0x243c, 0x3e04, 0x0e4c, - 0x0128, 0x1918, 0x253c, 0x3d04, 0x0d4c, - 0x0028, 0x1a18, 0x263c, 0x3c04, 0x0c4c, - 0x002c, 0x1b18, 0x273c, 0x3c08, 0x0c50, - 0x012c, 0x1c18, 0x283c, 0x3d08, 0x0d50, - 0x022c, 0x1d18, 0x293c, 0x3e08, 0x0e50, - 0x032c, 0x1d1c, 0x2940, 0x3f08, 0x0f50, - 0x042c, 0x1c1c, 0x2840, 0x4008, 0x1050, - 0x052c, 0x1b1c, 0x2740, 0x4108, 0x1150, - 0x0530, 0x1a1c, 0x2640, 0x410c, 0x1154, - 0x0430, 0x191c, 0x2540, 0x400c, 0x1054, - 0x0330, 0x181c, 0x2440, 0x3f0c, 0x0f54, - 0x0230, 0x1820, 0x2444, 0x3e0c, 0x0e54, - 0x0130, 0x1920, 0x2544, 0x3d0c, 0x0d54, - 0x0030, 0x1a20, 0x2644, 0x3c0c, 0x0c54, - 0x0034, 0x1b20, 0x2744, 0x3c10, 0x0c58, - 0x0134, 0x1c20, 0x2844, 0x3d10, 0x0e58, - 0x0234, 0x1d20, 0x2944, 0x3e10, 0x1058, - 0x0624, 0x2110, 0x2d34, 0x4200, 0x1248, - 0x0724, 0x2210, 0x2e34, 0x4300, 0x1348, - 0x0824, 0x2310, 0x2f34, 0x4400, 0x1448, - 0x0924, 0x2314, 0x2f38, 0x4500, 0x1548, - 0x0a24, 0x2214, 0x2e38, 0x4600, 0x1648, - 0x0b24, 0x2114, 0x2d38, 0x4700, 0x1748, - 0x0b28, 0x2014, 0x2c38, 0x4704, 0x174c, - 0x0a28, 0x1f14, 0x2b38, 0x4604, 0x164c, - 0x0928, 0x1e14, 0x2a38, 0x4504, 0x154c, - 0x0828, 0x1e18, 0x2a3c, 0x4404, 0x144c, - 0x0728, 0x1f18, 0x2b3c, 0x4304, 0x134c, - 0x0628, 0x2018, 0x2c3c, 0x4204, 0x124c, - 0x062c, 0x2118, 0x2d3c, 0x4208, 0x1250, - 0x072c, 0x2218, 0x2e3c, 0x4308, 0x1350, - 0x082c, 0x2318, 0x2f3c, 0x4408, 0x1450, - 0x092c, 0x231c, 0x2f40, 0x4508, 0x1550, - 0x0a2c, 0x221c, 0x2e40, 0x4608, 0x1650, - 0x0b2c, 0x211c, 0x2d40, 0x4708, 0x1750, - 0x0b30, 0x201c, 0x2c40, 0x470c, 0x1754, - 0x0a30, 0x1f1c, 0x2b40, 0x460c, 0x1654, - 0x0930, 0x1e1c, 0x2a40, 0x450c, 0x1554, - 0x0830, 0x1e20, 0x2a44, 0x440c, 0x1454, - 0x0730, 0x1f20, 0x2b44, 0x430c, 0x1354, - 0x0630, 0x2020, 0x2c44, 0x420c, 0x1254, - 0x0634, 0x2120, 0x2d44, 0x4210, 0x1258, - 0x0734, 0x2220, 0x2e44, 0x4310, 0x1458, - 0x0834, 0x2320, 0x2f44, 0x4410, 0x1658, -}; - -static const uint16_t dv_place_411[1350] = { - 0x0c24, 0x2710, 0x3334, 0x0000, 0x1848, - 0x0d24, 0x2810, 0x3434, 0x0100, 0x1948, - 0x0e24, 0x2910, 0x3534, 0x0200, 0x1a48, - 0x0f24, 0x2914, 0x3538, 0x0300, 0x1b48, - 0x1024, 0x2814, 0x3438, 0x0400, 0x1c48, - 0x1124, 0x2714, 0x3338, 0x0500, 0x1d48, - 0x1128, 0x2614, 0x3238, 0x0504, 0x1d4c, - 0x1028, 0x2514, 0x3138, 0x0404, 0x1c4c, - 0x0f28, 0x2414, 0x3038, 0x0304, 0x1b4c, - 0x0e28, 0x2418, 0x303c, 0x0204, 0x1a4c, - 0x0d28, 0x2518, 0x313c, 0x0104, 0x194c, - 0x0c28, 0x2618, 0x323c, 0x0004, 0x184c, - 0x0c2c, 0x2718, 0x333c, 0x0008, 0x1850, - 0x0d2c, 0x2818, 0x343c, 0x0108, 0x1950, - 0x0e2c, 0x2918, 0x353c, 0x0208, 0x1a50, - 0x0f2c, 0x291c, 0x3540, 0x0308, 0x1b50, - 0x102c, 0x281c, 0x3440, 0x0408, 0x1c50, - 0x112c, 0x271c, 0x3340, 0x0508, 0x1d50, - 0x1130, 0x261c, 0x3240, 0x050c, 0x1d54, - 0x1030, 0x251c, 0x3140, 0x040c, 0x1c54, - 0x0f30, 0x241c, 0x3040, 0x030c, 0x1b54, - 0x0e30, 0x2420, 0x3044, 0x020c, 0x1a54, - 0x0d30, 0x2520, 0x3144, 0x010c, 0x1954, - 0x0c30, 0x2620, 0x3244, 0x000c, 0x1854, - 0x0c34, 0x2720, 0x3344, 0x0010, 0x1858, - 0x0d34, 0x2820, 0x3444, 0x0110, 0x1a58, - 0x0e34, 0x2920, 0x3544, 0x0210, 0x1c58, - 0x1224, 0x2d10, 0x3934, 0x0600, 0x1e48, - 0x1324, 0x2e10, 0x3a34, 0x0700, 0x1f48, - 0x1424, 0x2f10, 0x3b34, 0x0800, 0x2048, - 0x1524, 0x2f14, 0x3b38, 0x0900, 0x2148, - 0x1624, 0x2e14, 0x3a38, 0x0a00, 0x2248, - 0x1724, 0x2d14, 0x3938, 0x0b00, 0x2348, - 0x1728, 0x2c14, 0x3838, 0x0b04, 0x234c, - 0x1628, 0x2b14, 0x3738, 0x0a04, 0x224c, - 0x1528, 0x2a14, 0x3638, 0x0904, 0x214c, - 0x1428, 0x2a18, 0x363c, 0x0804, 0x204c, - 0x1328, 0x2b18, 0x373c, 0x0704, 0x1f4c, - 0x1228, 0x2c18, 0x383c, 0x0604, 0x1e4c, - 0x122c, 0x2d18, 0x393c, 0x0608, 0x1e50, - 0x132c, 0x2e18, 0x3a3c, 0x0708, 0x1f50, - 0x142c, 0x2f18, 0x3b3c, 0x0808, 0x2050, - 0x152c, 0x2f1c, 0x3b40, 0x0908, 0x2150, - 0x162c, 0x2e1c, 0x3a40, 0x0a08, 0x2250, - 0x172c, 0x2d1c, 0x3940, 0x0b08, 0x2350, - 0x1730, 0x2c1c, 0x3840, 0x0b0c, 0x2354, - 0x1630, 0x2b1c, 0x3740, 0x0a0c, 0x2254, - 0x1530, 0x2a1c, 0x3640, 0x090c, 0x2154, - 0x1430, 0x2a20, 0x3644, 0x080c, 0x2054, - 0x1330, 0x2b20, 0x3744, 0x070c, 0x1f54, - 0x1230, 0x2c20, 0x3844, 0x060c, 0x1e54, - 0x1234, 0x2d20, 0x3944, 0x0610, 0x1e58, - 0x1334, 0x2e20, 0x3a44, 0x0710, 0x2058, - 0x1434, 0x2f20, 0x3b44, 0x0810, 0x2258, - 0x1824, 0x3310, 0x0334, 0x0c00, 0x2448, - 0x1924, 0x3410, 0x0434, 0x0d00, 0x2548, - 0x1a24, 0x3510, 0x0534, 0x0e00, 0x2648, - 0x1b24, 0x3514, 0x0538, 0x0f00, 0x2748, - 0x1c24, 0x3414, 0x0438, 0x1000, 0x2848, - 0x1d24, 0x3314, 0x0338, 0x1100, 0x2948, - 0x1d28, 0x3214, 0x0238, 0x1104, 0x294c, - 0x1c28, 0x3114, 0x0138, 0x1004, 0x284c, - 0x1b28, 0x3014, 0x0038, 0x0f04, 0x274c, - 0x1a28, 0x3018, 0x003c, 0x0e04, 0x264c, - 0x1928, 0x3118, 0x013c, 0x0d04, 0x254c, - 0x1828, 0x3218, 0x023c, 0x0c04, 0x244c, - 0x182c, 0x3318, 0x033c, 0x0c08, 0x2450, - 0x192c, 0x3418, 0x043c, 0x0d08, 0x2550, - 0x1a2c, 0x3518, 0x053c, 0x0e08, 0x2650, - 0x1b2c, 0x351c, 0x0540, 0x0f08, 0x2750, - 0x1c2c, 0x341c, 0x0440, 0x1008, 0x2850, - 0x1d2c, 0x331c, 0x0340, 0x1108, 0x2950, - 0x1d30, 0x321c, 0x0240, 0x110c, 0x2954, - 0x1c30, 0x311c, 0x0140, 0x100c, 0x2854, - 0x1b30, 0x301c, 0x0040, 0x0f0c, 0x2754, - 0x1a30, 0x3020, 0x0044, 0x0e0c, 0x2654, - 0x1930, 0x3120, 0x0144, 0x0d0c, 0x2554, - 0x1830, 0x3220, 0x0244, 0x0c0c, 0x2454, - 0x1834, 0x3320, 0x0344, 0x0c10, 0x2458, - 0x1934, 0x3420, 0x0444, 0x0d10, 0x2658, - 0x1a34, 0x3520, 0x0544, 0x0e10, 0x2858, - 0x1e24, 0x3910, 0x0934, 0x1200, 0x2a48, - 0x1f24, 0x3a10, 0x0a34, 0x1300, 0x2b48, - 0x2024, 0x3b10, 0x0b34, 0x1400, 0x2c48, - 0x2124, 0x3b14, 0x0b38, 0x1500, 0x2d48, - 0x2224, 0x3a14, 0x0a38, 0x1600, 0x2e48, - 0x2324, 0x3914, 0x0938, 0x1700, 0x2f48, - 0x2328, 0x3814, 0x0838, 0x1704, 0x2f4c, - 0x2228, 0x3714, 0x0738, 0x1604, 0x2e4c, - 0x2128, 0x3614, 0x0638, 0x1504, 0x2d4c, - 0x2028, 0x3618, 0x063c, 0x1404, 0x2c4c, - 0x1f28, 0x3718, 0x073c, 0x1304, 0x2b4c, - 0x1e28, 0x3818, 0x083c, 0x1204, 0x2a4c, - 0x1e2c, 0x3918, 0x093c, 0x1208, 0x2a50, - 0x1f2c, 0x3a18, 0x0a3c, 0x1308, 0x2b50, - 0x202c, 0x3b18, 0x0b3c, 0x1408, 0x2c50, - 0x212c, 0x3b1c, 0x0b40, 0x1508, 0x2d50, - 0x222c, 0x3a1c, 0x0a40, 0x1608, 0x2e50, - 0x232c, 0x391c, 0x0940, 0x1708, 0x2f50, - 0x2330, 0x381c, 0x0840, 0x170c, 0x2f54, - 0x2230, 0x371c, 0x0740, 0x160c, 0x2e54, - 0x2130, 0x361c, 0x0640, 0x150c, 0x2d54, - 0x2030, 0x3620, 0x0644, 0x140c, 0x2c54, - 0x1f30, 0x3720, 0x0744, 0x130c, 0x2b54, - 0x1e30, 0x3820, 0x0844, 0x120c, 0x2a54, - 0x1e34, 0x3920, 0x0944, 0x1210, 0x2a58, - 0x1f34, 0x3a20, 0x0a44, 0x1310, 0x2c58, - 0x2034, 0x3b20, 0x0b44, 0x1410, 0x2e58, - 0x2424, 0x0310, 0x0f34, 0x1800, 0x3048, - 0x2524, 0x0410, 0x1034, 0x1900, 0x3148, - 0x2624, 0x0510, 0x1134, 0x1a00, 0x3248, - 0x2724, 0x0514, 0x1138, 0x1b00, 0x3348, - 0x2824, 0x0414, 0x1038, 0x1c00, 0x3448, - 0x2924, 0x0314, 0x0f38, 0x1d00, 0x3548, - 0x2928, 0x0214, 0x0e38, 0x1d04, 0x354c, - 0x2828, 0x0114, 0x0d38, 0x1c04, 0x344c, - 0x2728, 0x0014, 0x0c38, 0x1b04, 0x334c, - 0x2628, 0x0018, 0x0c3c, 0x1a04, 0x324c, - 0x2528, 0x0118, 0x0d3c, 0x1904, 0x314c, - 0x2428, 0x0218, 0x0e3c, 0x1804, 0x304c, - 0x242c, 0x0318, 0x0f3c, 0x1808, 0x3050, - 0x252c, 0x0418, 0x103c, 0x1908, 0x3150, - 0x262c, 0x0518, 0x113c, 0x1a08, 0x3250, - 0x272c, 0x051c, 0x1140, 0x1b08, 0x3350, - 0x282c, 0x041c, 0x1040, 0x1c08, 0x3450, - 0x292c, 0x031c, 0x0f40, 0x1d08, 0x3550, - 0x2930, 0x021c, 0x0e40, 0x1d0c, 0x3554, - 0x2830, 0x011c, 0x0d40, 0x1c0c, 0x3454, - 0x2730, 0x001c, 0x0c40, 0x1b0c, 0x3354, - 0x2630, 0x0020, 0x0c44, 0x1a0c, 0x3254, - 0x2530, 0x0120, 0x0d44, 0x190c, 0x3154, - 0x2430, 0x0220, 0x0e44, 0x180c, 0x3054, - 0x2434, 0x0320, 0x0f44, 0x1810, 0x3058, - 0x2534, 0x0420, 0x1044, 0x1910, 0x3258, - 0x2634, 0x0520, 0x1144, 0x1a10, 0x3458, - 0x2a24, 0x0910, 0x1534, 0x1e00, 0x3648, - 0x2b24, 0x0a10, 0x1634, 0x1f00, 0x3748, - 0x2c24, 0x0b10, 0x1734, 0x2000, 0x3848, - 0x2d24, 0x0b14, 0x1738, 0x2100, 0x3948, - 0x2e24, 0x0a14, 0x1638, 0x2200, 0x3a48, - 0x2f24, 0x0914, 0x1538, 0x2300, 0x3b48, - 0x2f28, 0x0814, 0x1438, 0x2304, 0x3b4c, - 0x2e28, 0x0714, 0x1338, 0x2204, 0x3a4c, - 0x2d28, 0x0614, 0x1238, 0x2104, 0x394c, - 0x2c28, 0x0618, 0x123c, 0x2004, 0x384c, - 0x2b28, 0x0718, 0x133c, 0x1f04, 0x374c, - 0x2a28, 0x0818, 0x143c, 0x1e04, 0x364c, - 0x2a2c, 0x0918, 0x153c, 0x1e08, 0x3650, - 0x2b2c, 0x0a18, 0x163c, 0x1f08, 0x3750, - 0x2c2c, 0x0b18, 0x173c, 0x2008, 0x3850, - 0x2d2c, 0x0b1c, 0x1740, 0x2108, 0x3950, - 0x2e2c, 0x0a1c, 0x1640, 0x2208, 0x3a50, - 0x2f2c, 0x091c, 0x1540, 0x2308, 0x3b50, - 0x2f30, 0x081c, 0x1440, 0x230c, 0x3b54, - 0x2e30, 0x071c, 0x1340, 0x220c, 0x3a54, - 0x2d30, 0x061c, 0x1240, 0x210c, 0x3954, - 0x2c30, 0x0620, 0x1244, 0x200c, 0x3854, - 0x2b30, 0x0720, 0x1344, 0x1f0c, 0x3754, - 0x2a30, 0x0820, 0x1444, 0x1e0c, 0x3654, - 0x2a34, 0x0920, 0x1544, 0x1e10, 0x3658, - 0x2b34, 0x0a20, 0x1644, 0x1f10, 0x3858, - 0x2c34, 0x0b20, 0x1744, 0x2010, 0x3a58, - 0x3024, 0x0f10, 0x1b34, 0x2400, 0x0048, - 0x3124, 0x1010, 0x1c34, 0x2500, 0x0148, - 0x3224, 0x1110, 0x1d34, 0x2600, 0x0248, - 0x3324, 0x1114, 0x1d38, 0x2700, 0x0348, - 0x3424, 0x1014, 0x1c38, 0x2800, 0x0448, - 0x3524, 0x0f14, 0x1b38, 0x2900, 0x0548, - 0x3528, 0x0e14, 0x1a38, 0x2904, 0x054c, - 0x3428, 0x0d14, 0x1938, 0x2804, 0x044c, - 0x3328, 0x0c14, 0x1838, 0x2704, 0x034c, - 0x3228, 0x0c18, 0x183c, 0x2604, 0x024c, - 0x3128, 0x0d18, 0x193c, 0x2504, 0x014c, - 0x3028, 0x0e18, 0x1a3c, 0x2404, 0x004c, - 0x302c, 0x0f18, 0x1b3c, 0x2408, 0x0050, - 0x312c, 0x1018, 0x1c3c, 0x2508, 0x0150, - 0x322c, 0x1118, 0x1d3c, 0x2608, 0x0250, - 0x332c, 0x111c, 0x1d40, 0x2708, 0x0350, - 0x342c, 0x101c, 0x1c40, 0x2808, 0x0450, - 0x352c, 0x0f1c, 0x1b40, 0x2908, 0x0550, - 0x3530, 0x0e1c, 0x1a40, 0x290c, 0x0554, - 0x3430, 0x0d1c, 0x1940, 0x280c, 0x0454, - 0x3330, 0x0c1c, 0x1840, 0x270c, 0x0354, - 0x3230, 0x0c20, 0x1844, 0x260c, 0x0254, - 0x3130, 0x0d20, 0x1944, 0x250c, 0x0154, - 0x3030, 0x0e20, 0x1a44, 0x240c, 0x0054, - 0x3034, 0x0f20, 0x1b44, 0x2410, 0x0058, - 0x3134, 0x1020, 0x1c44, 0x2510, 0x0258, - 0x3234, 0x1120, 0x1d44, 0x2610, 0x0458, - 0x3624, 0x1510, 0x2134, 0x2a00, 0x0648, - 0x3724, 0x1610, 0x2234, 0x2b00, 0x0748, - 0x3824, 0x1710, 0x2334, 0x2c00, 0x0848, - 0x3924, 0x1714, 0x2338, 0x2d00, 0x0948, - 0x3a24, 0x1614, 0x2238, 0x2e00, 0x0a48, - 0x3b24, 0x1514, 0x2138, 0x2f00, 0x0b48, - 0x3b28, 0x1414, 0x2038, 0x2f04, 0x0b4c, - 0x3a28, 0x1314, 0x1f38, 0x2e04, 0x0a4c, - 0x3928, 0x1214, 0x1e38, 0x2d04, 0x094c, - 0x3828, 0x1218, 0x1e3c, 0x2c04, 0x084c, - 0x3728, 0x1318, 0x1f3c, 0x2b04, 0x074c, - 0x3628, 0x1418, 0x203c, 0x2a04, 0x064c, - 0x362c, 0x1518, 0x213c, 0x2a08, 0x0650, - 0x372c, 0x1618, 0x223c, 0x2b08, 0x0750, - 0x382c, 0x1718, 0x233c, 0x2c08, 0x0850, - 0x392c, 0x171c, 0x2340, 0x2d08, 0x0950, - 0x3a2c, 0x161c, 0x2240, 0x2e08, 0x0a50, - 0x3b2c, 0x151c, 0x2140, 0x2f08, 0x0b50, - 0x3b30, 0x141c, 0x2040, 0x2f0c, 0x0b54, - 0x3a30, 0x131c, 0x1f40, 0x2e0c, 0x0a54, - 0x3930, 0x121c, 0x1e40, 0x2d0c, 0x0954, - 0x3830, 0x1220, 0x1e44, 0x2c0c, 0x0854, - 0x3730, 0x1320, 0x1f44, 0x2b0c, 0x0754, - 0x3630, 0x1420, 0x2044, 0x2a0c, 0x0654, - 0x3634, 0x1520, 0x2144, 0x2a10, 0x0658, - 0x3734, 0x1620, 0x2244, 0x2b10, 0x0858, - 0x3834, 0x1720, 0x2344, 0x2c10, 0x0a58, - 0x0024, 0x1b10, 0x2734, 0x3000, 0x0c48, - 0x0124, 0x1c10, 0x2834, 0x3100, 0x0d48, - 0x0224, 0x1d10, 0x2934, 0x3200, 0x0e48, - 0x0324, 0x1d14, 0x2938, 0x3300, 0x0f48, - 0x0424, 0x1c14, 0x2838, 0x3400, 0x1048, - 0x0524, 0x1b14, 0x2738, 0x3500, 0x1148, - 0x0528, 0x1a14, 0x2638, 0x3504, 0x114c, - 0x0428, 0x1914, 0x2538, 0x3404, 0x104c, - 0x0328, 0x1814, 0x2438, 0x3304, 0x0f4c, - 0x0228, 0x1818, 0x243c, 0x3204, 0x0e4c, - 0x0128, 0x1918, 0x253c, 0x3104, 0x0d4c, - 0x0028, 0x1a18, 0x263c, 0x3004, 0x0c4c, - 0x002c, 0x1b18, 0x273c, 0x3008, 0x0c50, - 0x012c, 0x1c18, 0x283c, 0x3108, 0x0d50, - 0x022c, 0x1d18, 0x293c, 0x3208, 0x0e50, - 0x032c, 0x1d1c, 0x2940, 0x3308, 0x0f50, - 0x042c, 0x1c1c, 0x2840, 0x3408, 0x1050, - 0x052c, 0x1b1c, 0x2740, 0x3508, 0x1150, - 0x0530, 0x1a1c, 0x2640, 0x350c, 0x1154, - 0x0430, 0x191c, 0x2540, 0x340c, 0x1054, - 0x0330, 0x181c, 0x2440, 0x330c, 0x0f54, - 0x0230, 0x1820, 0x2444, 0x320c, 0x0e54, - 0x0130, 0x1920, 0x2544, 0x310c, 0x0d54, - 0x0030, 0x1a20, 0x2644, 0x300c, 0x0c54, - 0x0034, 0x1b20, 0x2744, 0x3010, 0x0c58, - 0x0134, 0x1c20, 0x2844, 0x3110, 0x0e58, - 0x0234, 0x1d20, 0x2944, 0x3210, 0x1058, - 0x0624, 0x2110, 0x2d34, 0x3600, 0x1248, - 0x0724, 0x2210, 0x2e34, 0x3700, 0x1348, - 0x0824, 0x2310, 0x2f34, 0x3800, 0x1448, - 0x0924, 0x2314, 0x2f38, 0x3900, 0x1548, - 0x0a24, 0x2214, 0x2e38, 0x3a00, 0x1648, - 0x0b24, 0x2114, 0x2d38, 0x3b00, 0x1748, - 0x0b28, 0x2014, 0x2c38, 0x3b04, 0x174c, - 0x0a28, 0x1f14, 0x2b38, 0x3a04, 0x164c, - 0x0928, 0x1e14, 0x2a38, 0x3904, 0x154c, - 0x0828, 0x1e18, 0x2a3c, 0x3804, 0x144c, - 0x0728, 0x1f18, 0x2b3c, 0x3704, 0x134c, - 0x0628, 0x2018, 0x2c3c, 0x3604, 0x124c, - 0x062c, 0x2118, 0x2d3c, 0x3608, 0x1250, - 0x072c, 0x2218, 0x2e3c, 0x3708, 0x1350, - 0x082c, 0x2318, 0x2f3c, 0x3808, 0x1450, - 0x092c, 0x231c, 0x2f40, 0x3908, 0x1550, - 0x0a2c, 0x221c, 0x2e40, 0x3a08, 0x1650, - 0x0b2c, 0x211c, 0x2d40, 0x3b08, 0x1750, - 0x0b30, 0x201c, 0x2c40, 0x3b0c, 0x1754, - 0x0a30, 0x1f1c, 0x2b40, 0x3a0c, 0x1654, - 0x0930, 0x1e1c, 0x2a40, 0x390c, 0x1554, - 0x0830, 0x1e20, 0x2a44, 0x380c, 0x1454, - 0x0730, 0x1f20, 0x2b44, 0x370c, 0x1354, - 0x0630, 0x2020, 0x2c44, 0x360c, 0x1254, - 0x0634, 0x2120, 0x2d44, 0x3610, 0x1258, - 0x0734, 0x2220, 0x2e44, 0x3710, 0x1458, - 0x0834, 0x2320, 0x2f44, 0x3810, 0x1658, -}; - -/* 4:2:2 macroblock placement tables created by dvtables.py */ - -/* 2 channels per frame, 10 DIF sequences per channel, - 27 video segments per DIF sequence, 5 macroblocks per video segment */ -static const uint16_t dv_place_422_525[2*10*27*5] = { - 0x0c48, 0x2424, 0x306c, 0x0000, 0x1890, - 0x0d48, 0x2524, 0x316c, 0x0100, 0x1990, - 0x0e48, 0x2624, 0x326c, 0x0200, 0x1a90, - 0x0e4c, 0x2628, 0x3270, 0x0204, 0x1a94, - 0x0d4c, 0x2528, 0x3170, 0x0104, 0x1994, - 0x0c4c, 0x2428, 0x3070, 0x0004, 0x1894, - 0x0c50, 0x242c, 0x3074, 0x0008, 0x1898, - 0x0d50, 0x252c, 0x3174, 0x0108, 0x1998, - 0x0e50, 0x262c, 0x3274, 0x0208, 0x1a98, - 0x0e54, 0x2630, 0x3278, 0x020c, 0x1a9c, - 0x0d54, 0x2530, 0x3178, 0x010c, 0x199c, - 0x0c54, 0x2430, 0x3078, 0x000c, 0x189c, - 0x0c58, 0x2434, 0x307c, 0x0010, 0x18a0, - 0x0d58, 0x2534, 0x317c, 0x0110, 0x19a0, - 0x0e58, 0x2634, 0x327c, 0x0210, 0x1aa0, - 0x0e5c, 0x2638, 0x3280, 0x0214, 0x1aa4, - 0x0d5c, 0x2538, 0x3180, 0x0114, 0x19a4, - 0x0c5c, 0x2438, 0x3080, 0x0014, 0x18a4, - 0x0c60, 0x243c, 0x3084, 0x0018, 0x18a8, - 0x0d60, 0x253c, 0x3184, 0x0118, 0x19a8, - 0x0e60, 0x263c, 0x3284, 0x0218, 0x1aa8, - 0x0e64, 0x2640, 0x3288, 0x021c, 0x1aac, - 0x0d64, 0x2540, 0x3188, 0x011c, 0x19ac, - 0x0c64, 0x2440, 0x3088, 0x001c, 0x18ac, - 0x0c68, 0x2444, 0x308c, 0x0020, 0x18b0, - 0x0d68, 0x2544, 0x318c, 0x0120, 0x19b0, - 0x0e68, 0x2644, 0x328c, 0x0220, 0x1ab0, - 0x1248, 0x2a24, 0x366c, 0x0600, 0x1e90, - 0x1348, 0x2b24, 0x376c, 0x0700, 0x1f90, - 0x1448, 0x2c24, 0x386c, 0x0800, 0x2090, - 0x144c, 0x2c28, 0x3870, 0x0804, 0x2094, - 0x134c, 0x2b28, 0x3770, 0x0704, 0x1f94, - 0x124c, 0x2a28, 0x3670, 0x0604, 0x1e94, - 0x1250, 0x2a2c, 0x3674, 0x0608, 0x1e98, - 0x1350, 0x2b2c, 0x3774, 0x0708, 0x1f98, - 0x1450, 0x2c2c, 0x3874, 0x0808, 0x2098, - 0x1454, 0x2c30, 0x3878, 0x080c, 0x209c, - 0x1354, 0x2b30, 0x3778, 0x070c, 0x1f9c, - 0x1254, 0x2a30, 0x3678, 0x060c, 0x1e9c, - 0x1258, 0x2a34, 0x367c, 0x0610, 0x1ea0, - 0x1358, 0x2b34, 0x377c, 0x0710, 0x1fa0, - 0x1458, 0x2c34, 0x387c, 0x0810, 0x20a0, - 0x145c, 0x2c38, 0x3880, 0x0814, 0x20a4, - 0x135c, 0x2b38, 0x3780, 0x0714, 0x1fa4, - 0x125c, 0x2a38, 0x3680, 0x0614, 0x1ea4, - 0x1260, 0x2a3c, 0x3684, 0x0618, 0x1ea8, - 0x1360, 0x2b3c, 0x3784, 0x0718, 0x1fa8, - 0x1460, 0x2c3c, 0x3884, 0x0818, 0x20a8, - 0x1464, 0x2c40, 0x3888, 0x081c, 0x20ac, - 0x1364, 0x2b40, 0x3788, 0x071c, 0x1fac, - 0x1264, 0x2a40, 0x3688, 0x061c, 0x1eac, - 0x1268, 0x2a44, 0x368c, 0x0620, 0x1eb0, - 0x1368, 0x2b44, 0x378c, 0x0720, 0x1fb0, - 0x1468, 0x2c44, 0x388c, 0x0820, 0x20b0, - 0x1848, 0x3024, 0x006c, 0x0c00, 0x2490, - 0x1948, 0x3124, 0x016c, 0x0d00, 0x2590, - 0x1a48, 0x3224, 0x026c, 0x0e00, 0x2690, - 0x1a4c, 0x3228, 0x0270, 0x0e04, 0x2694, - 0x194c, 0x3128, 0x0170, 0x0d04, 0x2594, - 0x184c, 0x3028, 0x0070, 0x0c04, 0x2494, - 0x1850, 0x302c, 0x0074, 0x0c08, 0x2498, - 0x1950, 0x312c, 0x0174, 0x0d08, 0x2598, - 0x1a50, 0x322c, 0x0274, 0x0e08, 0x2698, - 0x1a54, 0x3230, 0x0278, 0x0e0c, 0x269c, - 0x1954, 0x3130, 0x0178, 0x0d0c, 0x259c, - 0x1854, 0x3030, 0x0078, 0x0c0c, 0x249c, - 0x1858, 0x3034, 0x007c, 0x0c10, 0x24a0, - 0x1958, 0x3134, 0x017c, 0x0d10, 0x25a0, - 0x1a58, 0x3234, 0x027c, 0x0e10, 0x26a0, - 0x1a5c, 0x3238, 0x0280, 0x0e14, 0x26a4, - 0x195c, 0x3138, 0x0180, 0x0d14, 0x25a4, - 0x185c, 0x3038, 0x0080, 0x0c14, 0x24a4, - 0x1860, 0x303c, 0x0084, 0x0c18, 0x24a8, - 0x1960, 0x313c, 0x0184, 0x0d18, 0x25a8, - 0x1a60, 0x323c, 0x0284, 0x0e18, 0x26a8, - 0x1a64, 0x3240, 0x0288, 0x0e1c, 0x26ac, - 0x1964, 0x3140, 0x0188, 0x0d1c, 0x25ac, - 0x1864, 0x3040, 0x0088, 0x0c1c, 0x24ac, - 0x1868, 0x3044, 0x008c, 0x0c20, 0x24b0, - 0x1968, 0x3144, 0x018c, 0x0d20, 0x25b0, - 0x1a68, 0x3244, 0x028c, 0x0e20, 0x26b0, - 0x1e48, 0x3624, 0x066c, 0x1200, 0x2a90, - 0x1f48, 0x3724, 0x076c, 0x1300, 0x2b90, - 0x2048, 0x3824, 0x086c, 0x1400, 0x2c90, - 0x204c, 0x3828, 0x0870, 0x1404, 0x2c94, - 0x1f4c, 0x3728, 0x0770, 0x1304, 0x2b94, - 0x1e4c, 0x3628, 0x0670, 0x1204, 0x2a94, - 0x1e50, 0x362c, 0x0674, 0x1208, 0x2a98, - 0x1f50, 0x372c, 0x0774, 0x1308, 0x2b98, - 0x2050, 0x382c, 0x0874, 0x1408, 0x2c98, - 0x2054, 0x3830, 0x0878, 0x140c, 0x2c9c, - 0x1f54, 0x3730, 0x0778, 0x130c, 0x2b9c, - 0x1e54, 0x3630, 0x0678, 0x120c, 0x2a9c, - 0x1e58, 0x3634, 0x067c, 0x1210, 0x2aa0, - 0x1f58, 0x3734, 0x077c, 0x1310, 0x2ba0, - 0x2058, 0x3834, 0x087c, 0x1410, 0x2ca0, - 0x205c, 0x3838, 0x0880, 0x1414, 0x2ca4, - 0x1f5c, 0x3738, 0x0780, 0x1314, 0x2ba4, - 0x1e5c, 0x3638, 0x0680, 0x1214, 0x2aa4, - 0x1e60, 0x363c, 0x0684, 0x1218, 0x2aa8, - 0x1f60, 0x373c, 0x0784, 0x1318, 0x2ba8, - 0x2060, 0x383c, 0x0884, 0x1418, 0x2ca8, - 0x2064, 0x3840, 0x0888, 0x141c, 0x2cac, - 0x1f64, 0x3740, 0x0788, 0x131c, 0x2bac, - 0x1e64, 0x3640, 0x0688, 0x121c, 0x2aac, - 0x1e68, 0x3644, 0x068c, 0x1220, 0x2ab0, - 0x1f68, 0x3744, 0x078c, 0x1320, 0x2bb0, - 0x2068, 0x3844, 0x088c, 0x1420, 0x2cb0, - 0x2448, 0x0024, 0x0c6c, 0x1800, 0x3090, - 0x2548, 0x0124, 0x0d6c, 0x1900, 0x3190, - 0x2648, 0x0224, 0x0e6c, 0x1a00, 0x3290, - 0x264c, 0x0228, 0x0e70, 0x1a04, 0x3294, - 0x254c, 0x0128, 0x0d70, 0x1904, 0x3194, - 0x244c, 0x0028, 0x0c70, 0x1804, 0x3094, - 0x2450, 0x002c, 0x0c74, 0x1808, 0x3098, - 0x2550, 0x012c, 0x0d74, 0x1908, 0x3198, - 0x2650, 0x022c, 0x0e74, 0x1a08, 0x3298, - 0x2654, 0x0230, 0x0e78, 0x1a0c, 0x329c, - 0x2554, 0x0130, 0x0d78, 0x190c, 0x319c, - 0x2454, 0x0030, 0x0c78, 0x180c, 0x309c, - 0x2458, 0x0034, 0x0c7c, 0x1810, 0x30a0, - 0x2558, 0x0134, 0x0d7c, 0x1910, 0x31a0, - 0x2658, 0x0234, 0x0e7c, 0x1a10, 0x32a0, - 0x265c, 0x0238, 0x0e80, 0x1a14, 0x32a4, - 0x255c, 0x0138, 0x0d80, 0x1914, 0x31a4, - 0x245c, 0x0038, 0x0c80, 0x1814, 0x30a4, - 0x2460, 0x003c, 0x0c84, 0x1818, 0x30a8, - 0x2560, 0x013c, 0x0d84, 0x1918, 0x31a8, - 0x2660, 0x023c, 0x0e84, 0x1a18, 0x32a8, - 0x2664, 0x0240, 0x0e88, 0x1a1c, 0x32ac, - 0x2564, 0x0140, 0x0d88, 0x191c, 0x31ac, - 0x2464, 0x0040, 0x0c88, 0x181c, 0x30ac, - 0x2468, 0x0044, 0x0c8c, 0x1820, 0x30b0, - 0x2568, 0x0144, 0x0d8c, 0x1920, 0x31b0, - 0x2668, 0x0244, 0x0e8c, 0x1a20, 0x32b0, - 0x2a48, 0x0624, 0x126c, 0x1e00, 0x3690, - 0x2b48, 0x0724, 0x136c, 0x1f00, 0x3790, - 0x2c48, 0x0824, 0x146c, 0x2000, 0x3890, - 0x2c4c, 0x0828, 0x1470, 0x2004, 0x3894, - 0x2b4c, 0x0728, 0x1370, 0x1f04, 0x3794, - 0x2a4c, 0x0628, 0x1270, 0x1e04, 0x3694, - 0x2a50, 0x062c, 0x1274, 0x1e08, 0x3698, - 0x2b50, 0x072c, 0x1374, 0x1f08, 0x3798, - 0x2c50, 0x082c, 0x1474, 0x2008, 0x3898, - 0x2c54, 0x0830, 0x1478, 0x200c, 0x389c, - 0x2b54, 0x0730, 0x1378, 0x1f0c, 0x379c, - 0x2a54, 0x0630, 0x1278, 0x1e0c, 0x369c, - 0x2a58, 0x0634, 0x127c, 0x1e10, 0x36a0, - 0x2b58, 0x0734, 0x137c, 0x1f10, 0x37a0, - 0x2c58, 0x0834, 0x147c, 0x2010, 0x38a0, - 0x2c5c, 0x0838, 0x1480, 0x2014, 0x38a4, - 0x2b5c, 0x0738, 0x1380, 0x1f14, 0x37a4, - 0x2a5c, 0x0638, 0x1280, 0x1e14, 0x36a4, - 0x2a60, 0x063c, 0x1284, 0x1e18, 0x36a8, - 0x2b60, 0x073c, 0x1384, 0x1f18, 0x37a8, - 0x2c60, 0x083c, 0x1484, 0x2018, 0x38a8, - 0x2c64, 0x0840, 0x1488, 0x201c, 0x38ac, - 0x2b64, 0x0740, 0x1388, 0x1f1c, 0x37ac, - 0x2a64, 0x0640, 0x1288, 0x1e1c, 0x36ac, - 0x2a68, 0x0644, 0x128c, 0x1e20, 0x36b0, - 0x2b68, 0x0744, 0x138c, 0x1f20, 0x37b0, - 0x2c68, 0x0844, 0x148c, 0x2020, 0x38b0, - 0x3048, 0x0c24, 0x186c, 0x2400, 0x0090, - 0x3148, 0x0d24, 0x196c, 0x2500, 0x0190, - 0x3248, 0x0e24, 0x1a6c, 0x2600, 0x0290, - 0x324c, 0x0e28, 0x1a70, 0x2604, 0x0294, - 0x314c, 0x0d28, 0x1970, 0x2504, 0x0194, - 0x304c, 0x0c28, 0x1870, 0x2404, 0x0094, - 0x3050, 0x0c2c, 0x1874, 0x2408, 0x0098, - 0x3150, 0x0d2c, 0x1974, 0x2508, 0x0198, - 0x3250, 0x0e2c, 0x1a74, 0x2608, 0x0298, - 0x3254, 0x0e30, 0x1a78, 0x260c, 0x029c, - 0x3154, 0x0d30, 0x1978, 0x250c, 0x019c, - 0x3054, 0x0c30, 0x1878, 0x240c, 0x009c, - 0x3058, 0x0c34, 0x187c, 0x2410, 0x00a0, - 0x3158, 0x0d34, 0x197c, 0x2510, 0x01a0, - 0x3258, 0x0e34, 0x1a7c, 0x2610, 0x02a0, - 0x325c, 0x0e38, 0x1a80, 0x2614, 0x02a4, - 0x315c, 0x0d38, 0x1980, 0x2514, 0x01a4, - 0x305c, 0x0c38, 0x1880, 0x2414, 0x00a4, - 0x3060, 0x0c3c, 0x1884, 0x2418, 0x00a8, - 0x3160, 0x0d3c, 0x1984, 0x2518, 0x01a8, - 0x3260, 0x0e3c, 0x1a84, 0x2618, 0x02a8, - 0x3264, 0x0e40, 0x1a88, 0x261c, 0x02ac, - 0x3164, 0x0d40, 0x1988, 0x251c, 0x01ac, - 0x3064, 0x0c40, 0x1888, 0x241c, 0x00ac, - 0x3068, 0x0c44, 0x188c, 0x2420, 0x00b0, - 0x3168, 0x0d44, 0x198c, 0x2520, 0x01b0, - 0x3268, 0x0e44, 0x1a8c, 0x2620, 0x02b0, - 0x3648, 0x1224, 0x1e6c, 0x2a00, 0x0690, - 0x3748, 0x1324, 0x1f6c, 0x2b00, 0x0790, - 0x3848, 0x1424, 0x206c, 0x2c00, 0x0890, - 0x384c, 0x1428, 0x2070, 0x2c04, 0x0894, - 0x374c, 0x1328, 0x1f70, 0x2b04, 0x0794, - 0x364c, 0x1228, 0x1e70, 0x2a04, 0x0694, - 0x3650, 0x122c, 0x1e74, 0x2a08, 0x0698, - 0x3750, 0x132c, 0x1f74, 0x2b08, 0x0798, - 0x3850, 0x142c, 0x2074, 0x2c08, 0x0898, - 0x3854, 0x1430, 0x2078, 0x2c0c, 0x089c, - 0x3754, 0x1330, 0x1f78, 0x2b0c, 0x079c, - 0x3654, 0x1230, 0x1e78, 0x2a0c, 0x069c, - 0x3658, 0x1234, 0x1e7c, 0x2a10, 0x06a0, - 0x3758, 0x1334, 0x1f7c, 0x2b10, 0x07a0, - 0x3858, 0x1434, 0x207c, 0x2c10, 0x08a0, - 0x385c, 0x1438, 0x2080, 0x2c14, 0x08a4, - 0x375c, 0x1338, 0x1f80, 0x2b14, 0x07a4, - 0x365c, 0x1238, 0x1e80, 0x2a14, 0x06a4, - 0x3660, 0x123c, 0x1e84, 0x2a18, 0x06a8, - 0x3760, 0x133c, 0x1f84, 0x2b18, 0x07a8, - 0x3860, 0x143c, 0x2084, 0x2c18, 0x08a8, - 0x3864, 0x1440, 0x2088, 0x2c1c, 0x08ac, - 0x3764, 0x1340, 0x1f88, 0x2b1c, 0x07ac, - 0x3664, 0x1240, 0x1e88, 0x2a1c, 0x06ac, - 0x3668, 0x1244, 0x1e8c, 0x2a20, 0x06b0, - 0x3768, 0x1344, 0x1f8c, 0x2b20, 0x07b0, - 0x3868, 0x1444, 0x208c, 0x2c20, 0x08b0, - 0x0048, 0x1824, 0x246c, 0x3000, 0x0c90, - 0x0148, 0x1924, 0x256c, 0x3100, 0x0d90, - 0x0248, 0x1a24, 0x266c, 0x3200, 0x0e90, - 0x024c, 0x1a28, 0x2670, 0x3204, 0x0e94, - 0x014c, 0x1928, 0x2570, 0x3104, 0x0d94, - 0x004c, 0x1828, 0x2470, 0x3004, 0x0c94, - 0x0050, 0x182c, 0x2474, 0x3008, 0x0c98, - 0x0150, 0x192c, 0x2574, 0x3108, 0x0d98, - 0x0250, 0x1a2c, 0x2674, 0x3208, 0x0e98, - 0x0254, 0x1a30, 0x2678, 0x320c, 0x0e9c, - 0x0154, 0x1930, 0x2578, 0x310c, 0x0d9c, - 0x0054, 0x1830, 0x2478, 0x300c, 0x0c9c, - 0x0058, 0x1834, 0x247c, 0x3010, 0x0ca0, - 0x0158, 0x1934, 0x257c, 0x3110, 0x0da0, - 0x0258, 0x1a34, 0x267c, 0x3210, 0x0ea0, - 0x025c, 0x1a38, 0x2680, 0x3214, 0x0ea4, - 0x015c, 0x1938, 0x2580, 0x3114, 0x0da4, - 0x005c, 0x1838, 0x2480, 0x3014, 0x0ca4, - 0x0060, 0x183c, 0x2484, 0x3018, 0x0ca8, - 0x0160, 0x193c, 0x2584, 0x3118, 0x0da8, - 0x0260, 0x1a3c, 0x2684, 0x3218, 0x0ea8, - 0x0264, 0x1a40, 0x2688, 0x321c, 0x0eac, - 0x0164, 0x1940, 0x2588, 0x311c, 0x0dac, - 0x0064, 0x1840, 0x2488, 0x301c, 0x0cac, - 0x0068, 0x1844, 0x248c, 0x3020, 0x0cb0, - 0x0168, 0x1944, 0x258c, 0x3120, 0x0db0, - 0x0268, 0x1a44, 0x268c, 0x3220, 0x0eb0, - 0x0648, 0x1e24, 0x2a6c, 0x3600, 0x1290, - 0x0748, 0x1f24, 0x2b6c, 0x3700, 0x1390, - 0x0848, 0x2024, 0x2c6c, 0x3800, 0x1490, - 0x084c, 0x2028, 0x2c70, 0x3804, 0x1494, - 0x074c, 0x1f28, 0x2b70, 0x3704, 0x1394, - 0x064c, 0x1e28, 0x2a70, 0x3604, 0x1294, - 0x0650, 0x1e2c, 0x2a74, 0x3608, 0x1298, - 0x0750, 0x1f2c, 0x2b74, 0x3708, 0x1398, - 0x0850, 0x202c, 0x2c74, 0x3808, 0x1498, - 0x0854, 0x2030, 0x2c78, 0x380c, 0x149c, - 0x0754, 0x1f30, 0x2b78, 0x370c, 0x139c, - 0x0654, 0x1e30, 0x2a78, 0x360c, 0x129c, - 0x0658, 0x1e34, 0x2a7c, 0x3610, 0x12a0, - 0x0758, 0x1f34, 0x2b7c, 0x3710, 0x13a0, - 0x0858, 0x2034, 0x2c7c, 0x3810, 0x14a0, - 0x085c, 0x2038, 0x2c80, 0x3814, 0x14a4, - 0x075c, 0x1f38, 0x2b80, 0x3714, 0x13a4, - 0x065c, 0x1e38, 0x2a80, 0x3614, 0x12a4, - 0x0660, 0x1e3c, 0x2a84, 0x3618, 0x12a8, - 0x0760, 0x1f3c, 0x2b84, 0x3718, 0x13a8, - 0x0860, 0x203c, 0x2c84, 0x3818, 0x14a8, - 0x0864, 0x2040, 0x2c88, 0x381c, 0x14ac, - 0x0764, 0x1f40, 0x2b88, 0x371c, 0x13ac, - 0x0664, 0x1e40, 0x2a88, 0x361c, 0x12ac, - 0x0668, 0x1e44, 0x2a8c, 0x3620, 0x12b0, - 0x0768, 0x1f44, 0x2b8c, 0x3720, 0x13b0, - 0x0868, 0x2044, 0x2c8c, 0x3820, 0x14b0, - 0x0f48, 0x2724, 0x336c, 0x0300, 0x1b90, - 0x1048, 0x2824, 0x346c, 0x0400, 0x1c90, - 0x1148, 0x2924, 0x356c, 0x0500, 0x1d90, - 0x114c, 0x2928, 0x3570, 0x0504, 0x1d94, - 0x104c, 0x2828, 0x3470, 0x0404, 0x1c94, - 0x0f4c, 0x2728, 0x3370, 0x0304, 0x1b94, - 0x0f50, 0x272c, 0x3374, 0x0308, 0x1b98, - 0x1050, 0x282c, 0x3474, 0x0408, 0x1c98, - 0x1150, 0x292c, 0x3574, 0x0508, 0x1d98, - 0x1154, 0x2930, 0x3578, 0x050c, 0x1d9c, - 0x1054, 0x2830, 0x3478, 0x040c, 0x1c9c, - 0x0f54, 0x2730, 0x3378, 0x030c, 0x1b9c, - 0x0f58, 0x2734, 0x337c, 0x0310, 0x1ba0, - 0x1058, 0x2834, 0x347c, 0x0410, 0x1ca0, - 0x1158, 0x2934, 0x357c, 0x0510, 0x1da0, - 0x115c, 0x2938, 0x3580, 0x0514, 0x1da4, - 0x105c, 0x2838, 0x3480, 0x0414, 0x1ca4, - 0x0f5c, 0x2738, 0x3380, 0x0314, 0x1ba4, - 0x0f60, 0x273c, 0x3384, 0x0318, 0x1ba8, - 0x1060, 0x283c, 0x3484, 0x0418, 0x1ca8, - 0x1160, 0x293c, 0x3584, 0x0518, 0x1da8, - 0x1164, 0x2940, 0x3588, 0x051c, 0x1dac, - 0x1064, 0x2840, 0x3488, 0x041c, 0x1cac, - 0x0f64, 0x2740, 0x3388, 0x031c, 0x1bac, - 0x0f68, 0x2744, 0x338c, 0x0320, 0x1bb0, - 0x1068, 0x2844, 0x348c, 0x0420, 0x1cb0, - 0x1168, 0x2944, 0x358c, 0x0520, 0x1db0, - 0x1548, 0x2d24, 0x396c, 0x0900, 0x2190, - 0x1648, 0x2e24, 0x3a6c, 0x0a00, 0x2290, - 0x1748, 0x2f24, 0x3b6c, 0x0b00, 0x2390, - 0x174c, 0x2f28, 0x3b70, 0x0b04, 0x2394, - 0x164c, 0x2e28, 0x3a70, 0x0a04, 0x2294, - 0x154c, 0x2d28, 0x3970, 0x0904, 0x2194, - 0x1550, 0x2d2c, 0x3974, 0x0908, 0x2198, - 0x1650, 0x2e2c, 0x3a74, 0x0a08, 0x2298, - 0x1750, 0x2f2c, 0x3b74, 0x0b08, 0x2398, - 0x1754, 0x2f30, 0x3b78, 0x0b0c, 0x239c, - 0x1654, 0x2e30, 0x3a78, 0x0a0c, 0x229c, - 0x1554, 0x2d30, 0x3978, 0x090c, 0x219c, - 0x1558, 0x2d34, 0x397c, 0x0910, 0x21a0, - 0x1658, 0x2e34, 0x3a7c, 0x0a10, 0x22a0, - 0x1758, 0x2f34, 0x3b7c, 0x0b10, 0x23a0, - 0x175c, 0x2f38, 0x3b80, 0x0b14, 0x23a4, - 0x165c, 0x2e38, 0x3a80, 0x0a14, 0x22a4, - 0x155c, 0x2d38, 0x3980, 0x0914, 0x21a4, - 0x1560, 0x2d3c, 0x3984, 0x0918, 0x21a8, - 0x1660, 0x2e3c, 0x3a84, 0x0a18, 0x22a8, - 0x1760, 0x2f3c, 0x3b84, 0x0b18, 0x23a8, - 0x1764, 0x2f40, 0x3b88, 0x0b1c, 0x23ac, - 0x1664, 0x2e40, 0x3a88, 0x0a1c, 0x22ac, - 0x1564, 0x2d40, 0x3988, 0x091c, 0x21ac, - 0x1568, 0x2d44, 0x398c, 0x0920, 0x21b0, - 0x1668, 0x2e44, 0x3a8c, 0x0a20, 0x22b0, - 0x1768, 0x2f44, 0x3b8c, 0x0b20, 0x23b0, - 0x1b48, 0x3324, 0x036c, 0x0f00, 0x2790, - 0x1c48, 0x3424, 0x046c, 0x1000, 0x2890, - 0x1d48, 0x3524, 0x056c, 0x1100, 0x2990, - 0x1d4c, 0x3528, 0x0570, 0x1104, 0x2994, - 0x1c4c, 0x3428, 0x0470, 0x1004, 0x2894, - 0x1b4c, 0x3328, 0x0370, 0x0f04, 0x2794, - 0x1b50, 0x332c, 0x0374, 0x0f08, 0x2798, - 0x1c50, 0x342c, 0x0474, 0x1008, 0x2898, - 0x1d50, 0x352c, 0x0574, 0x1108, 0x2998, - 0x1d54, 0x3530, 0x0578, 0x110c, 0x299c, - 0x1c54, 0x3430, 0x0478, 0x100c, 0x289c, - 0x1b54, 0x3330, 0x0378, 0x0f0c, 0x279c, - 0x1b58, 0x3334, 0x037c, 0x0f10, 0x27a0, - 0x1c58, 0x3434, 0x047c, 0x1010, 0x28a0, - 0x1d58, 0x3534, 0x057c, 0x1110, 0x29a0, - 0x1d5c, 0x3538, 0x0580, 0x1114, 0x29a4, - 0x1c5c, 0x3438, 0x0480, 0x1014, 0x28a4, - 0x1b5c, 0x3338, 0x0380, 0x0f14, 0x27a4, - 0x1b60, 0x333c, 0x0384, 0x0f18, 0x27a8, - 0x1c60, 0x343c, 0x0484, 0x1018, 0x28a8, - 0x1d60, 0x353c, 0x0584, 0x1118, 0x29a8, - 0x1d64, 0x3540, 0x0588, 0x111c, 0x29ac, - 0x1c64, 0x3440, 0x0488, 0x101c, 0x28ac, - 0x1b64, 0x3340, 0x0388, 0x0f1c, 0x27ac, - 0x1b68, 0x3344, 0x038c, 0x0f20, 0x27b0, - 0x1c68, 0x3444, 0x048c, 0x1020, 0x28b0, - 0x1d68, 0x3544, 0x058c, 0x1120, 0x29b0, - 0x2148, 0x3924, 0x096c, 0x1500, 0x2d90, - 0x2248, 0x3a24, 0x0a6c, 0x1600, 0x2e90, - 0x2348, 0x3b24, 0x0b6c, 0x1700, 0x2f90, - 0x234c, 0x3b28, 0x0b70, 0x1704, 0x2f94, - 0x224c, 0x3a28, 0x0a70, 0x1604, 0x2e94, - 0x214c, 0x3928, 0x0970, 0x1504, 0x2d94, - 0x2150, 0x392c, 0x0974, 0x1508, 0x2d98, - 0x2250, 0x3a2c, 0x0a74, 0x1608, 0x2e98, - 0x2350, 0x3b2c, 0x0b74, 0x1708, 0x2f98, - 0x2354, 0x3b30, 0x0b78, 0x170c, 0x2f9c, - 0x2254, 0x3a30, 0x0a78, 0x160c, 0x2e9c, - 0x2154, 0x3930, 0x0978, 0x150c, 0x2d9c, - 0x2158, 0x3934, 0x097c, 0x1510, 0x2da0, - 0x2258, 0x3a34, 0x0a7c, 0x1610, 0x2ea0, - 0x2358, 0x3b34, 0x0b7c, 0x1710, 0x2fa0, - 0x235c, 0x3b38, 0x0b80, 0x1714, 0x2fa4, - 0x225c, 0x3a38, 0x0a80, 0x1614, 0x2ea4, - 0x215c, 0x3938, 0x0980, 0x1514, 0x2da4, - 0x2160, 0x393c, 0x0984, 0x1518, 0x2da8, - 0x2260, 0x3a3c, 0x0a84, 0x1618, 0x2ea8, - 0x2360, 0x3b3c, 0x0b84, 0x1718, 0x2fa8, - 0x2364, 0x3b40, 0x0b88, 0x171c, 0x2fac, - 0x2264, 0x3a40, 0x0a88, 0x161c, 0x2eac, - 0x2164, 0x3940, 0x0988, 0x151c, 0x2dac, - 0x2168, 0x3944, 0x098c, 0x1520, 0x2db0, - 0x2268, 0x3a44, 0x0a8c, 0x1620, 0x2eb0, - 0x2368, 0x3b44, 0x0b8c, 0x1720, 0x2fb0, - 0x2748, 0x0324, 0x0f6c, 0x1b00, 0x3390, - 0x2848, 0x0424, 0x106c, 0x1c00, 0x3490, - 0x2948, 0x0524, 0x116c, 0x1d00, 0x3590, - 0x294c, 0x0528, 0x1170, 0x1d04, 0x3594, - 0x284c, 0x0428, 0x1070, 0x1c04, 0x3494, - 0x274c, 0x0328, 0x0f70, 0x1b04, 0x3394, - 0x2750, 0x032c, 0x0f74, 0x1b08, 0x3398, - 0x2850, 0x042c, 0x1074, 0x1c08, 0x3498, - 0x2950, 0x052c, 0x1174, 0x1d08, 0x3598, - 0x2954, 0x0530, 0x1178, 0x1d0c, 0x359c, - 0x2854, 0x0430, 0x1078, 0x1c0c, 0x349c, - 0x2754, 0x0330, 0x0f78, 0x1b0c, 0x339c, - 0x2758, 0x0334, 0x0f7c, 0x1b10, 0x33a0, - 0x2858, 0x0434, 0x107c, 0x1c10, 0x34a0, - 0x2958, 0x0534, 0x117c, 0x1d10, 0x35a0, - 0x295c, 0x0538, 0x1180, 0x1d14, 0x35a4, - 0x285c, 0x0438, 0x1080, 0x1c14, 0x34a4, - 0x275c, 0x0338, 0x0f80, 0x1b14, 0x33a4, - 0x2760, 0x033c, 0x0f84, 0x1b18, 0x33a8, - 0x2860, 0x043c, 0x1084, 0x1c18, 0x34a8, - 0x2960, 0x053c, 0x1184, 0x1d18, 0x35a8, - 0x2964, 0x0540, 0x1188, 0x1d1c, 0x35ac, - 0x2864, 0x0440, 0x1088, 0x1c1c, 0x34ac, - 0x2764, 0x0340, 0x0f88, 0x1b1c, 0x33ac, - 0x2768, 0x0344, 0x0f8c, 0x1b20, 0x33b0, - 0x2868, 0x0444, 0x108c, 0x1c20, 0x34b0, - 0x2968, 0x0544, 0x118c, 0x1d20, 0x35b0, - 0x2d48, 0x0924, 0x156c, 0x2100, 0x3990, - 0x2e48, 0x0a24, 0x166c, 0x2200, 0x3a90, - 0x2f48, 0x0b24, 0x176c, 0x2300, 0x3b90, - 0x2f4c, 0x0b28, 0x1770, 0x2304, 0x3b94, - 0x2e4c, 0x0a28, 0x1670, 0x2204, 0x3a94, - 0x2d4c, 0x0928, 0x1570, 0x2104, 0x3994, - 0x2d50, 0x092c, 0x1574, 0x2108, 0x3998, - 0x2e50, 0x0a2c, 0x1674, 0x2208, 0x3a98, - 0x2f50, 0x0b2c, 0x1774, 0x2308, 0x3b98, - 0x2f54, 0x0b30, 0x1778, 0x230c, 0x3b9c, - 0x2e54, 0x0a30, 0x1678, 0x220c, 0x3a9c, - 0x2d54, 0x0930, 0x1578, 0x210c, 0x399c, - 0x2d58, 0x0934, 0x157c, 0x2110, 0x39a0, - 0x2e58, 0x0a34, 0x167c, 0x2210, 0x3aa0, - 0x2f58, 0x0b34, 0x177c, 0x2310, 0x3ba0, - 0x2f5c, 0x0b38, 0x1780, 0x2314, 0x3ba4, - 0x2e5c, 0x0a38, 0x1680, 0x2214, 0x3aa4, - 0x2d5c, 0x0938, 0x1580, 0x2114, 0x39a4, - 0x2d60, 0x093c, 0x1584, 0x2118, 0x39a8, - 0x2e60, 0x0a3c, 0x1684, 0x2218, 0x3aa8, - 0x2f60, 0x0b3c, 0x1784, 0x2318, 0x3ba8, - 0x2f64, 0x0b40, 0x1788, 0x231c, 0x3bac, - 0x2e64, 0x0a40, 0x1688, 0x221c, 0x3aac, - 0x2d64, 0x0940, 0x1588, 0x211c, 0x39ac, - 0x2d68, 0x0944, 0x158c, 0x2120, 0x39b0, - 0x2e68, 0x0a44, 0x168c, 0x2220, 0x3ab0, - 0x2f68, 0x0b44, 0x178c, 0x2320, 0x3bb0, - 0x3348, 0x0f24, 0x1b6c, 0x2700, 0x0390, - 0x3448, 0x1024, 0x1c6c, 0x2800, 0x0490, - 0x3548, 0x1124, 0x1d6c, 0x2900, 0x0590, - 0x354c, 0x1128, 0x1d70, 0x2904, 0x0594, - 0x344c, 0x1028, 0x1c70, 0x2804, 0x0494, - 0x334c, 0x0f28, 0x1b70, 0x2704, 0x0394, - 0x3350, 0x0f2c, 0x1b74, 0x2708, 0x0398, - 0x3450, 0x102c, 0x1c74, 0x2808, 0x0498, - 0x3550, 0x112c, 0x1d74, 0x2908, 0x0598, - 0x3554, 0x1130, 0x1d78, 0x290c, 0x059c, - 0x3454, 0x1030, 0x1c78, 0x280c, 0x049c, - 0x3354, 0x0f30, 0x1b78, 0x270c, 0x039c, - 0x3358, 0x0f34, 0x1b7c, 0x2710, 0x03a0, - 0x3458, 0x1034, 0x1c7c, 0x2810, 0x04a0, - 0x3558, 0x1134, 0x1d7c, 0x2910, 0x05a0, - 0x355c, 0x1138, 0x1d80, 0x2914, 0x05a4, - 0x345c, 0x1038, 0x1c80, 0x2814, 0x04a4, - 0x335c, 0x0f38, 0x1b80, 0x2714, 0x03a4, - 0x3360, 0x0f3c, 0x1b84, 0x2718, 0x03a8, - 0x3460, 0x103c, 0x1c84, 0x2818, 0x04a8, - 0x3560, 0x113c, 0x1d84, 0x2918, 0x05a8, - 0x3564, 0x1140, 0x1d88, 0x291c, 0x05ac, - 0x3464, 0x1040, 0x1c88, 0x281c, 0x04ac, - 0x3364, 0x0f40, 0x1b88, 0x271c, 0x03ac, - 0x3368, 0x0f44, 0x1b8c, 0x2720, 0x03b0, - 0x3468, 0x1044, 0x1c8c, 0x2820, 0x04b0, - 0x3568, 0x1144, 0x1d8c, 0x2920, 0x05b0, - 0x3948, 0x1524, 0x216c, 0x2d00, 0x0990, - 0x3a48, 0x1624, 0x226c, 0x2e00, 0x0a90, - 0x3b48, 0x1724, 0x236c, 0x2f00, 0x0b90, - 0x3b4c, 0x1728, 0x2370, 0x2f04, 0x0b94, - 0x3a4c, 0x1628, 0x2270, 0x2e04, 0x0a94, - 0x394c, 0x1528, 0x2170, 0x2d04, 0x0994, - 0x3950, 0x152c, 0x2174, 0x2d08, 0x0998, - 0x3a50, 0x162c, 0x2274, 0x2e08, 0x0a98, - 0x3b50, 0x172c, 0x2374, 0x2f08, 0x0b98, - 0x3b54, 0x1730, 0x2378, 0x2f0c, 0x0b9c, - 0x3a54, 0x1630, 0x2278, 0x2e0c, 0x0a9c, - 0x3954, 0x1530, 0x2178, 0x2d0c, 0x099c, - 0x3958, 0x1534, 0x217c, 0x2d10, 0x09a0, - 0x3a58, 0x1634, 0x227c, 0x2e10, 0x0aa0, - 0x3b58, 0x1734, 0x237c, 0x2f10, 0x0ba0, - 0x3b5c, 0x1738, 0x2380, 0x2f14, 0x0ba4, - 0x3a5c, 0x1638, 0x2280, 0x2e14, 0x0aa4, - 0x395c, 0x1538, 0x2180, 0x2d14, 0x09a4, - 0x3960, 0x153c, 0x2184, 0x2d18, 0x09a8, - 0x3a60, 0x163c, 0x2284, 0x2e18, 0x0aa8, - 0x3b60, 0x173c, 0x2384, 0x2f18, 0x0ba8, - 0x3b64, 0x1740, 0x2388, 0x2f1c, 0x0bac, - 0x3a64, 0x1640, 0x2288, 0x2e1c, 0x0aac, - 0x3964, 0x1540, 0x2188, 0x2d1c, 0x09ac, - 0x3968, 0x1544, 0x218c, 0x2d20, 0x09b0, - 0x3a68, 0x1644, 0x228c, 0x2e20, 0x0ab0, - 0x3b68, 0x1744, 0x238c, 0x2f20, 0x0bb0, - 0x0348, 0x1b24, 0x276c, 0x3300, 0x0f90, - 0x0448, 0x1c24, 0x286c, 0x3400, 0x1090, - 0x0548, 0x1d24, 0x296c, 0x3500, 0x1190, - 0x054c, 0x1d28, 0x2970, 0x3504, 0x1194, - 0x044c, 0x1c28, 0x2870, 0x3404, 0x1094, - 0x034c, 0x1b28, 0x2770, 0x3304, 0x0f94, - 0x0350, 0x1b2c, 0x2774, 0x3308, 0x0f98, - 0x0450, 0x1c2c, 0x2874, 0x3408, 0x1098, - 0x0550, 0x1d2c, 0x2974, 0x3508, 0x1198, - 0x0554, 0x1d30, 0x2978, 0x350c, 0x119c, - 0x0454, 0x1c30, 0x2878, 0x340c, 0x109c, - 0x0354, 0x1b30, 0x2778, 0x330c, 0x0f9c, - 0x0358, 0x1b34, 0x277c, 0x3310, 0x0fa0, - 0x0458, 0x1c34, 0x287c, 0x3410, 0x10a0, - 0x0558, 0x1d34, 0x297c, 0x3510, 0x11a0, - 0x055c, 0x1d38, 0x2980, 0x3514, 0x11a4, - 0x045c, 0x1c38, 0x2880, 0x3414, 0x10a4, - 0x035c, 0x1b38, 0x2780, 0x3314, 0x0fa4, - 0x0360, 0x1b3c, 0x2784, 0x3318, 0x0fa8, - 0x0460, 0x1c3c, 0x2884, 0x3418, 0x10a8, - 0x0560, 0x1d3c, 0x2984, 0x3518, 0x11a8, - 0x0564, 0x1d40, 0x2988, 0x351c, 0x11ac, - 0x0464, 0x1c40, 0x2888, 0x341c, 0x10ac, - 0x0364, 0x1b40, 0x2788, 0x331c, 0x0fac, - 0x0368, 0x1b44, 0x278c, 0x3320, 0x0fb0, - 0x0468, 0x1c44, 0x288c, 0x3420, 0x10b0, - 0x0568, 0x1d44, 0x298c, 0x3520, 0x11b0, - 0x0948, 0x2124, 0x2d6c, 0x3900, 0x1590, - 0x0a48, 0x2224, 0x2e6c, 0x3a00, 0x1690, - 0x0b48, 0x2324, 0x2f6c, 0x3b00, 0x1790, - 0x0b4c, 0x2328, 0x2f70, 0x3b04, 0x1794, - 0x0a4c, 0x2228, 0x2e70, 0x3a04, 0x1694, - 0x094c, 0x2128, 0x2d70, 0x3904, 0x1594, - 0x0950, 0x212c, 0x2d74, 0x3908, 0x1598, - 0x0a50, 0x222c, 0x2e74, 0x3a08, 0x1698, - 0x0b50, 0x232c, 0x2f74, 0x3b08, 0x1798, - 0x0b54, 0x2330, 0x2f78, 0x3b0c, 0x179c, - 0x0a54, 0x2230, 0x2e78, 0x3a0c, 0x169c, - 0x0954, 0x2130, 0x2d78, 0x390c, 0x159c, - 0x0958, 0x2134, 0x2d7c, 0x3910, 0x15a0, - 0x0a58, 0x2234, 0x2e7c, 0x3a10, 0x16a0, - 0x0b58, 0x2334, 0x2f7c, 0x3b10, 0x17a0, - 0x0b5c, 0x2338, 0x2f80, 0x3b14, 0x17a4, - 0x0a5c, 0x2238, 0x2e80, 0x3a14, 0x16a4, - 0x095c, 0x2138, 0x2d80, 0x3914, 0x15a4, - 0x0960, 0x213c, 0x2d84, 0x3918, 0x15a8, - 0x0a60, 0x223c, 0x2e84, 0x3a18, 0x16a8, - 0x0b60, 0x233c, 0x2f84, 0x3b18, 0x17a8, - 0x0b64, 0x2340, 0x2f88, 0x3b1c, 0x17ac, - 0x0a64, 0x2240, 0x2e88, 0x3a1c, 0x16ac, - 0x0964, 0x2140, 0x2d88, 0x391c, 0x15ac, - 0x0968, 0x2144, 0x2d8c, 0x3920, 0x15b0, - 0x0a68, 0x2244, 0x2e8c, 0x3a20, 0x16b0, - 0x0b68, 0x2344, 0x2f8c, 0x3b20, 0x17b0, -}; - -/* 2 channels per frame, 12 DIF sequences per channel, - 27 video segments per DIF sequence, 5 macroblocks per video segment */ -static const uint16_t dv_place_422_625[2*12*27*5] = { - 0x0c48, 0x2424, 0x306c, 0x0000, 0x1890, - 0x0d48, 0x2524, 0x316c, 0x0100, 0x1990, - 0x0e48, 0x2624, 0x326c, 0x0200, 0x1a90, - 0x0e4c, 0x2628, 0x3270, 0x0204, 0x1a94, - 0x0d4c, 0x2528, 0x3170, 0x0104, 0x1994, - 0x0c4c, 0x2428, 0x3070, 0x0004, 0x1894, - 0x0c50, 0x242c, 0x3074, 0x0008, 0x1898, - 0x0d50, 0x252c, 0x3174, 0x0108, 0x1998, - 0x0e50, 0x262c, 0x3274, 0x0208, 0x1a98, - 0x0e54, 0x2630, 0x3278, 0x020c, 0x1a9c, - 0x0d54, 0x2530, 0x3178, 0x010c, 0x199c, - 0x0c54, 0x2430, 0x3078, 0x000c, 0x189c, - 0x0c58, 0x2434, 0x307c, 0x0010, 0x18a0, - 0x0d58, 0x2534, 0x317c, 0x0110, 0x19a0, - 0x0e58, 0x2634, 0x327c, 0x0210, 0x1aa0, - 0x0e5c, 0x2638, 0x3280, 0x0214, 0x1aa4, - 0x0d5c, 0x2538, 0x3180, 0x0114, 0x19a4, - 0x0c5c, 0x2438, 0x3080, 0x0014, 0x18a4, - 0x0c60, 0x243c, 0x3084, 0x0018, 0x18a8, - 0x0d60, 0x253c, 0x3184, 0x0118, 0x19a8, - 0x0e60, 0x263c, 0x3284, 0x0218, 0x1aa8, - 0x0e64, 0x2640, 0x3288, 0x021c, 0x1aac, - 0x0d64, 0x2540, 0x3188, 0x011c, 0x19ac, - 0x0c64, 0x2440, 0x3088, 0x001c, 0x18ac, - 0x0c68, 0x2444, 0x308c, 0x0020, 0x18b0, - 0x0d68, 0x2544, 0x318c, 0x0120, 0x19b0, - 0x0e68, 0x2644, 0x328c, 0x0220, 0x1ab0, - 0x1248, 0x2a24, 0x366c, 0x0600, 0x1e90, - 0x1348, 0x2b24, 0x376c, 0x0700, 0x1f90, - 0x1448, 0x2c24, 0x386c, 0x0800, 0x2090, - 0x144c, 0x2c28, 0x3870, 0x0804, 0x2094, - 0x134c, 0x2b28, 0x3770, 0x0704, 0x1f94, - 0x124c, 0x2a28, 0x3670, 0x0604, 0x1e94, - 0x1250, 0x2a2c, 0x3674, 0x0608, 0x1e98, - 0x1350, 0x2b2c, 0x3774, 0x0708, 0x1f98, - 0x1450, 0x2c2c, 0x3874, 0x0808, 0x2098, - 0x1454, 0x2c30, 0x3878, 0x080c, 0x209c, - 0x1354, 0x2b30, 0x3778, 0x070c, 0x1f9c, - 0x1254, 0x2a30, 0x3678, 0x060c, 0x1e9c, - 0x1258, 0x2a34, 0x367c, 0x0610, 0x1ea0, - 0x1358, 0x2b34, 0x377c, 0x0710, 0x1fa0, - 0x1458, 0x2c34, 0x387c, 0x0810, 0x20a0, - 0x145c, 0x2c38, 0x3880, 0x0814, 0x20a4, - 0x135c, 0x2b38, 0x3780, 0x0714, 0x1fa4, - 0x125c, 0x2a38, 0x3680, 0x0614, 0x1ea4, - 0x1260, 0x2a3c, 0x3684, 0x0618, 0x1ea8, - 0x1360, 0x2b3c, 0x3784, 0x0718, 0x1fa8, - 0x1460, 0x2c3c, 0x3884, 0x0818, 0x20a8, - 0x1464, 0x2c40, 0x3888, 0x081c, 0x20ac, - 0x1364, 0x2b40, 0x3788, 0x071c, 0x1fac, - 0x1264, 0x2a40, 0x3688, 0x061c, 0x1eac, - 0x1268, 0x2a44, 0x368c, 0x0620, 0x1eb0, - 0x1368, 0x2b44, 0x378c, 0x0720, 0x1fb0, - 0x1468, 0x2c44, 0x388c, 0x0820, 0x20b0, - 0x1848, 0x3024, 0x3c6c, 0x0c00, 0x2490, - 0x1948, 0x3124, 0x3d6c, 0x0d00, 0x2590, - 0x1a48, 0x3224, 0x3e6c, 0x0e00, 0x2690, - 0x1a4c, 0x3228, 0x3e70, 0x0e04, 0x2694, - 0x194c, 0x3128, 0x3d70, 0x0d04, 0x2594, - 0x184c, 0x3028, 0x3c70, 0x0c04, 0x2494, - 0x1850, 0x302c, 0x3c74, 0x0c08, 0x2498, - 0x1950, 0x312c, 0x3d74, 0x0d08, 0x2598, - 0x1a50, 0x322c, 0x3e74, 0x0e08, 0x2698, - 0x1a54, 0x3230, 0x3e78, 0x0e0c, 0x269c, - 0x1954, 0x3130, 0x3d78, 0x0d0c, 0x259c, - 0x1854, 0x3030, 0x3c78, 0x0c0c, 0x249c, - 0x1858, 0x3034, 0x3c7c, 0x0c10, 0x24a0, - 0x1958, 0x3134, 0x3d7c, 0x0d10, 0x25a0, - 0x1a58, 0x3234, 0x3e7c, 0x0e10, 0x26a0, - 0x1a5c, 0x3238, 0x3e80, 0x0e14, 0x26a4, - 0x195c, 0x3138, 0x3d80, 0x0d14, 0x25a4, - 0x185c, 0x3038, 0x3c80, 0x0c14, 0x24a4, - 0x1860, 0x303c, 0x3c84, 0x0c18, 0x24a8, - 0x1960, 0x313c, 0x3d84, 0x0d18, 0x25a8, - 0x1a60, 0x323c, 0x3e84, 0x0e18, 0x26a8, - 0x1a64, 0x3240, 0x3e88, 0x0e1c, 0x26ac, - 0x1964, 0x3140, 0x3d88, 0x0d1c, 0x25ac, - 0x1864, 0x3040, 0x3c88, 0x0c1c, 0x24ac, - 0x1868, 0x3044, 0x3c8c, 0x0c20, 0x24b0, - 0x1968, 0x3144, 0x3d8c, 0x0d20, 0x25b0, - 0x1a68, 0x3244, 0x3e8c, 0x0e20, 0x26b0, - 0x1e48, 0x3624, 0x426c, 0x1200, 0x2a90, - 0x1f48, 0x3724, 0x436c, 0x1300, 0x2b90, - 0x2048, 0x3824, 0x446c, 0x1400, 0x2c90, - 0x204c, 0x3828, 0x4470, 0x1404, 0x2c94, - 0x1f4c, 0x3728, 0x4370, 0x1304, 0x2b94, - 0x1e4c, 0x3628, 0x4270, 0x1204, 0x2a94, - 0x1e50, 0x362c, 0x4274, 0x1208, 0x2a98, - 0x1f50, 0x372c, 0x4374, 0x1308, 0x2b98, - 0x2050, 0x382c, 0x4474, 0x1408, 0x2c98, - 0x2054, 0x3830, 0x4478, 0x140c, 0x2c9c, - 0x1f54, 0x3730, 0x4378, 0x130c, 0x2b9c, - 0x1e54, 0x3630, 0x4278, 0x120c, 0x2a9c, - 0x1e58, 0x3634, 0x427c, 0x1210, 0x2aa0, - 0x1f58, 0x3734, 0x437c, 0x1310, 0x2ba0, - 0x2058, 0x3834, 0x447c, 0x1410, 0x2ca0, - 0x205c, 0x3838, 0x4480, 0x1414, 0x2ca4, - 0x1f5c, 0x3738, 0x4380, 0x1314, 0x2ba4, - 0x1e5c, 0x3638, 0x4280, 0x1214, 0x2aa4, - 0x1e60, 0x363c, 0x4284, 0x1218, 0x2aa8, - 0x1f60, 0x373c, 0x4384, 0x1318, 0x2ba8, - 0x2060, 0x383c, 0x4484, 0x1418, 0x2ca8, - 0x2064, 0x3840, 0x4488, 0x141c, 0x2cac, - 0x1f64, 0x3740, 0x4388, 0x131c, 0x2bac, - 0x1e64, 0x3640, 0x4288, 0x121c, 0x2aac, - 0x1e68, 0x3644, 0x428c, 0x1220, 0x2ab0, - 0x1f68, 0x3744, 0x438c, 0x1320, 0x2bb0, - 0x2068, 0x3844, 0x448c, 0x1420, 0x2cb0, - 0x2448, 0x3c24, 0x006c, 0x1800, 0x3090, - 0x2548, 0x3d24, 0x016c, 0x1900, 0x3190, - 0x2648, 0x3e24, 0x026c, 0x1a00, 0x3290, - 0x264c, 0x3e28, 0x0270, 0x1a04, 0x3294, - 0x254c, 0x3d28, 0x0170, 0x1904, 0x3194, - 0x244c, 0x3c28, 0x0070, 0x1804, 0x3094, - 0x2450, 0x3c2c, 0x0074, 0x1808, 0x3098, - 0x2550, 0x3d2c, 0x0174, 0x1908, 0x3198, - 0x2650, 0x3e2c, 0x0274, 0x1a08, 0x3298, - 0x2654, 0x3e30, 0x0278, 0x1a0c, 0x329c, - 0x2554, 0x3d30, 0x0178, 0x190c, 0x319c, - 0x2454, 0x3c30, 0x0078, 0x180c, 0x309c, - 0x2458, 0x3c34, 0x007c, 0x1810, 0x30a0, - 0x2558, 0x3d34, 0x017c, 0x1910, 0x31a0, - 0x2658, 0x3e34, 0x027c, 0x1a10, 0x32a0, - 0x265c, 0x3e38, 0x0280, 0x1a14, 0x32a4, - 0x255c, 0x3d38, 0x0180, 0x1914, 0x31a4, - 0x245c, 0x3c38, 0x0080, 0x1814, 0x30a4, - 0x2460, 0x3c3c, 0x0084, 0x1818, 0x30a8, - 0x2560, 0x3d3c, 0x0184, 0x1918, 0x31a8, - 0x2660, 0x3e3c, 0x0284, 0x1a18, 0x32a8, - 0x2664, 0x3e40, 0x0288, 0x1a1c, 0x32ac, - 0x2564, 0x3d40, 0x0188, 0x191c, 0x31ac, - 0x2464, 0x3c40, 0x0088, 0x181c, 0x30ac, - 0x2468, 0x3c44, 0x008c, 0x1820, 0x30b0, - 0x2568, 0x3d44, 0x018c, 0x1920, 0x31b0, - 0x2668, 0x3e44, 0x028c, 0x1a20, 0x32b0, - 0x2a48, 0x4224, 0x066c, 0x1e00, 0x3690, - 0x2b48, 0x4324, 0x076c, 0x1f00, 0x3790, - 0x2c48, 0x4424, 0x086c, 0x2000, 0x3890, - 0x2c4c, 0x4428, 0x0870, 0x2004, 0x3894, - 0x2b4c, 0x4328, 0x0770, 0x1f04, 0x3794, - 0x2a4c, 0x4228, 0x0670, 0x1e04, 0x3694, - 0x2a50, 0x422c, 0x0674, 0x1e08, 0x3698, - 0x2b50, 0x432c, 0x0774, 0x1f08, 0x3798, - 0x2c50, 0x442c, 0x0874, 0x2008, 0x3898, - 0x2c54, 0x4430, 0x0878, 0x200c, 0x389c, - 0x2b54, 0x4330, 0x0778, 0x1f0c, 0x379c, - 0x2a54, 0x4230, 0x0678, 0x1e0c, 0x369c, - 0x2a58, 0x4234, 0x067c, 0x1e10, 0x36a0, - 0x2b58, 0x4334, 0x077c, 0x1f10, 0x37a0, - 0x2c58, 0x4434, 0x087c, 0x2010, 0x38a0, - 0x2c5c, 0x4438, 0x0880, 0x2014, 0x38a4, - 0x2b5c, 0x4338, 0x0780, 0x1f14, 0x37a4, - 0x2a5c, 0x4238, 0x0680, 0x1e14, 0x36a4, - 0x2a60, 0x423c, 0x0684, 0x1e18, 0x36a8, - 0x2b60, 0x433c, 0x0784, 0x1f18, 0x37a8, - 0x2c60, 0x443c, 0x0884, 0x2018, 0x38a8, - 0x2c64, 0x4440, 0x0888, 0x201c, 0x38ac, - 0x2b64, 0x4340, 0x0788, 0x1f1c, 0x37ac, - 0x2a64, 0x4240, 0x0688, 0x1e1c, 0x36ac, - 0x2a68, 0x4244, 0x068c, 0x1e20, 0x36b0, - 0x2b68, 0x4344, 0x078c, 0x1f20, 0x37b0, - 0x2c68, 0x4444, 0x088c, 0x2020, 0x38b0, - 0x3048, 0x0024, 0x0c6c, 0x2400, 0x3c90, - 0x3148, 0x0124, 0x0d6c, 0x2500, 0x3d90, - 0x3248, 0x0224, 0x0e6c, 0x2600, 0x3e90, - 0x324c, 0x0228, 0x0e70, 0x2604, 0x3e94, - 0x314c, 0x0128, 0x0d70, 0x2504, 0x3d94, - 0x304c, 0x0028, 0x0c70, 0x2404, 0x3c94, - 0x3050, 0x002c, 0x0c74, 0x2408, 0x3c98, - 0x3150, 0x012c, 0x0d74, 0x2508, 0x3d98, - 0x3250, 0x022c, 0x0e74, 0x2608, 0x3e98, - 0x3254, 0x0230, 0x0e78, 0x260c, 0x3e9c, - 0x3154, 0x0130, 0x0d78, 0x250c, 0x3d9c, - 0x3054, 0x0030, 0x0c78, 0x240c, 0x3c9c, - 0x3058, 0x0034, 0x0c7c, 0x2410, 0x3ca0, - 0x3158, 0x0134, 0x0d7c, 0x2510, 0x3da0, - 0x3258, 0x0234, 0x0e7c, 0x2610, 0x3ea0, - 0x325c, 0x0238, 0x0e80, 0x2614, 0x3ea4, - 0x315c, 0x0138, 0x0d80, 0x2514, 0x3da4, - 0x305c, 0x0038, 0x0c80, 0x2414, 0x3ca4, - 0x3060, 0x003c, 0x0c84, 0x2418, 0x3ca8, - 0x3160, 0x013c, 0x0d84, 0x2518, 0x3da8, - 0x3260, 0x023c, 0x0e84, 0x2618, 0x3ea8, - 0x3264, 0x0240, 0x0e88, 0x261c, 0x3eac, - 0x3164, 0x0140, 0x0d88, 0x251c, 0x3dac, - 0x3064, 0x0040, 0x0c88, 0x241c, 0x3cac, - 0x3068, 0x0044, 0x0c8c, 0x2420, 0x3cb0, - 0x3168, 0x0144, 0x0d8c, 0x2520, 0x3db0, - 0x3268, 0x0244, 0x0e8c, 0x2620, 0x3eb0, - 0x3648, 0x0624, 0x126c, 0x2a00, 0x4290, - 0x3748, 0x0724, 0x136c, 0x2b00, 0x4390, - 0x3848, 0x0824, 0x146c, 0x2c00, 0x4490, - 0x384c, 0x0828, 0x1470, 0x2c04, 0x4494, - 0x374c, 0x0728, 0x1370, 0x2b04, 0x4394, - 0x364c, 0x0628, 0x1270, 0x2a04, 0x4294, - 0x3650, 0x062c, 0x1274, 0x2a08, 0x4298, - 0x3750, 0x072c, 0x1374, 0x2b08, 0x4398, - 0x3850, 0x082c, 0x1474, 0x2c08, 0x4498, - 0x3854, 0x0830, 0x1478, 0x2c0c, 0x449c, - 0x3754, 0x0730, 0x1378, 0x2b0c, 0x439c, - 0x3654, 0x0630, 0x1278, 0x2a0c, 0x429c, - 0x3658, 0x0634, 0x127c, 0x2a10, 0x42a0, - 0x3758, 0x0734, 0x137c, 0x2b10, 0x43a0, - 0x3858, 0x0834, 0x147c, 0x2c10, 0x44a0, - 0x385c, 0x0838, 0x1480, 0x2c14, 0x44a4, - 0x375c, 0x0738, 0x1380, 0x2b14, 0x43a4, - 0x365c, 0x0638, 0x1280, 0x2a14, 0x42a4, - 0x3660, 0x063c, 0x1284, 0x2a18, 0x42a8, - 0x3760, 0x073c, 0x1384, 0x2b18, 0x43a8, - 0x3860, 0x083c, 0x1484, 0x2c18, 0x44a8, - 0x3864, 0x0840, 0x1488, 0x2c1c, 0x44ac, - 0x3764, 0x0740, 0x1388, 0x2b1c, 0x43ac, - 0x3664, 0x0640, 0x1288, 0x2a1c, 0x42ac, - 0x3668, 0x0644, 0x128c, 0x2a20, 0x42b0, - 0x3768, 0x0744, 0x138c, 0x2b20, 0x43b0, - 0x3868, 0x0844, 0x148c, 0x2c20, 0x44b0, - 0x3c48, 0x0c24, 0x186c, 0x3000, 0x0090, - 0x3d48, 0x0d24, 0x196c, 0x3100, 0x0190, - 0x3e48, 0x0e24, 0x1a6c, 0x3200, 0x0290, - 0x3e4c, 0x0e28, 0x1a70, 0x3204, 0x0294, - 0x3d4c, 0x0d28, 0x1970, 0x3104, 0x0194, - 0x3c4c, 0x0c28, 0x1870, 0x3004, 0x0094, - 0x3c50, 0x0c2c, 0x1874, 0x3008, 0x0098, - 0x3d50, 0x0d2c, 0x1974, 0x3108, 0x0198, - 0x3e50, 0x0e2c, 0x1a74, 0x3208, 0x0298, - 0x3e54, 0x0e30, 0x1a78, 0x320c, 0x029c, - 0x3d54, 0x0d30, 0x1978, 0x310c, 0x019c, - 0x3c54, 0x0c30, 0x1878, 0x300c, 0x009c, - 0x3c58, 0x0c34, 0x187c, 0x3010, 0x00a0, - 0x3d58, 0x0d34, 0x197c, 0x3110, 0x01a0, - 0x3e58, 0x0e34, 0x1a7c, 0x3210, 0x02a0, - 0x3e5c, 0x0e38, 0x1a80, 0x3214, 0x02a4, - 0x3d5c, 0x0d38, 0x1980, 0x3114, 0x01a4, - 0x3c5c, 0x0c38, 0x1880, 0x3014, 0x00a4, - 0x3c60, 0x0c3c, 0x1884, 0x3018, 0x00a8, - 0x3d60, 0x0d3c, 0x1984, 0x3118, 0x01a8, - 0x3e60, 0x0e3c, 0x1a84, 0x3218, 0x02a8, - 0x3e64, 0x0e40, 0x1a88, 0x321c, 0x02ac, - 0x3d64, 0x0d40, 0x1988, 0x311c, 0x01ac, - 0x3c64, 0x0c40, 0x1888, 0x301c, 0x00ac, - 0x3c68, 0x0c44, 0x188c, 0x3020, 0x00b0, - 0x3d68, 0x0d44, 0x198c, 0x3120, 0x01b0, - 0x3e68, 0x0e44, 0x1a8c, 0x3220, 0x02b0, - 0x4248, 0x1224, 0x1e6c, 0x3600, 0x0690, - 0x4348, 0x1324, 0x1f6c, 0x3700, 0x0790, - 0x4448, 0x1424, 0x206c, 0x3800, 0x0890, - 0x444c, 0x1428, 0x2070, 0x3804, 0x0894, - 0x434c, 0x1328, 0x1f70, 0x3704, 0x0794, - 0x424c, 0x1228, 0x1e70, 0x3604, 0x0694, - 0x4250, 0x122c, 0x1e74, 0x3608, 0x0698, - 0x4350, 0x132c, 0x1f74, 0x3708, 0x0798, - 0x4450, 0x142c, 0x2074, 0x3808, 0x0898, - 0x4454, 0x1430, 0x2078, 0x380c, 0x089c, - 0x4354, 0x1330, 0x1f78, 0x370c, 0x079c, - 0x4254, 0x1230, 0x1e78, 0x360c, 0x069c, - 0x4258, 0x1234, 0x1e7c, 0x3610, 0x06a0, - 0x4358, 0x1334, 0x1f7c, 0x3710, 0x07a0, - 0x4458, 0x1434, 0x207c, 0x3810, 0x08a0, - 0x445c, 0x1438, 0x2080, 0x3814, 0x08a4, - 0x435c, 0x1338, 0x1f80, 0x3714, 0x07a4, - 0x425c, 0x1238, 0x1e80, 0x3614, 0x06a4, - 0x4260, 0x123c, 0x1e84, 0x3618, 0x06a8, - 0x4360, 0x133c, 0x1f84, 0x3718, 0x07a8, - 0x4460, 0x143c, 0x2084, 0x3818, 0x08a8, - 0x4464, 0x1440, 0x2088, 0x381c, 0x08ac, - 0x4364, 0x1340, 0x1f88, 0x371c, 0x07ac, - 0x4264, 0x1240, 0x1e88, 0x361c, 0x06ac, - 0x4268, 0x1244, 0x1e8c, 0x3620, 0x06b0, - 0x4368, 0x1344, 0x1f8c, 0x3720, 0x07b0, - 0x4468, 0x1444, 0x208c, 0x3820, 0x08b0, - 0x0048, 0x1824, 0x246c, 0x3c00, 0x0c90, - 0x0148, 0x1924, 0x256c, 0x3d00, 0x0d90, - 0x0248, 0x1a24, 0x266c, 0x3e00, 0x0e90, - 0x024c, 0x1a28, 0x2670, 0x3e04, 0x0e94, - 0x014c, 0x1928, 0x2570, 0x3d04, 0x0d94, - 0x004c, 0x1828, 0x2470, 0x3c04, 0x0c94, - 0x0050, 0x182c, 0x2474, 0x3c08, 0x0c98, - 0x0150, 0x192c, 0x2574, 0x3d08, 0x0d98, - 0x0250, 0x1a2c, 0x2674, 0x3e08, 0x0e98, - 0x0254, 0x1a30, 0x2678, 0x3e0c, 0x0e9c, - 0x0154, 0x1930, 0x2578, 0x3d0c, 0x0d9c, - 0x0054, 0x1830, 0x2478, 0x3c0c, 0x0c9c, - 0x0058, 0x1834, 0x247c, 0x3c10, 0x0ca0, - 0x0158, 0x1934, 0x257c, 0x3d10, 0x0da0, - 0x0258, 0x1a34, 0x267c, 0x3e10, 0x0ea0, - 0x025c, 0x1a38, 0x2680, 0x3e14, 0x0ea4, - 0x015c, 0x1938, 0x2580, 0x3d14, 0x0da4, - 0x005c, 0x1838, 0x2480, 0x3c14, 0x0ca4, - 0x0060, 0x183c, 0x2484, 0x3c18, 0x0ca8, - 0x0160, 0x193c, 0x2584, 0x3d18, 0x0da8, - 0x0260, 0x1a3c, 0x2684, 0x3e18, 0x0ea8, - 0x0264, 0x1a40, 0x2688, 0x3e1c, 0x0eac, - 0x0164, 0x1940, 0x2588, 0x3d1c, 0x0dac, - 0x0064, 0x1840, 0x2488, 0x3c1c, 0x0cac, - 0x0068, 0x1844, 0x248c, 0x3c20, 0x0cb0, - 0x0168, 0x1944, 0x258c, 0x3d20, 0x0db0, - 0x0268, 0x1a44, 0x268c, 0x3e20, 0x0eb0, - 0x0648, 0x1e24, 0x2a6c, 0x4200, 0x1290, - 0x0748, 0x1f24, 0x2b6c, 0x4300, 0x1390, - 0x0848, 0x2024, 0x2c6c, 0x4400, 0x1490, - 0x084c, 0x2028, 0x2c70, 0x4404, 0x1494, - 0x074c, 0x1f28, 0x2b70, 0x4304, 0x1394, - 0x064c, 0x1e28, 0x2a70, 0x4204, 0x1294, - 0x0650, 0x1e2c, 0x2a74, 0x4208, 0x1298, - 0x0750, 0x1f2c, 0x2b74, 0x4308, 0x1398, - 0x0850, 0x202c, 0x2c74, 0x4408, 0x1498, - 0x0854, 0x2030, 0x2c78, 0x440c, 0x149c, - 0x0754, 0x1f30, 0x2b78, 0x430c, 0x139c, - 0x0654, 0x1e30, 0x2a78, 0x420c, 0x129c, - 0x0658, 0x1e34, 0x2a7c, 0x4210, 0x12a0, - 0x0758, 0x1f34, 0x2b7c, 0x4310, 0x13a0, - 0x0858, 0x2034, 0x2c7c, 0x4410, 0x14a0, - 0x085c, 0x2038, 0x2c80, 0x4414, 0x14a4, - 0x075c, 0x1f38, 0x2b80, 0x4314, 0x13a4, - 0x065c, 0x1e38, 0x2a80, 0x4214, 0x12a4, - 0x0660, 0x1e3c, 0x2a84, 0x4218, 0x12a8, - 0x0760, 0x1f3c, 0x2b84, 0x4318, 0x13a8, - 0x0860, 0x203c, 0x2c84, 0x4418, 0x14a8, - 0x0864, 0x2040, 0x2c88, 0x441c, 0x14ac, - 0x0764, 0x1f40, 0x2b88, 0x431c, 0x13ac, - 0x0664, 0x1e40, 0x2a88, 0x421c, 0x12ac, - 0x0668, 0x1e44, 0x2a8c, 0x4220, 0x12b0, - 0x0768, 0x1f44, 0x2b8c, 0x4320, 0x13b0, - 0x0868, 0x2044, 0x2c8c, 0x4420, 0x14b0, - 0x0f48, 0x2724, 0x336c, 0x0300, 0x1b90, - 0x1048, 0x2824, 0x346c, 0x0400, 0x1c90, - 0x1148, 0x2924, 0x356c, 0x0500, 0x1d90, - 0x114c, 0x2928, 0x3570, 0x0504, 0x1d94, - 0x104c, 0x2828, 0x3470, 0x0404, 0x1c94, - 0x0f4c, 0x2728, 0x3370, 0x0304, 0x1b94, - 0x0f50, 0x272c, 0x3374, 0x0308, 0x1b98, - 0x1050, 0x282c, 0x3474, 0x0408, 0x1c98, - 0x1150, 0x292c, 0x3574, 0x0508, 0x1d98, - 0x1154, 0x2930, 0x3578, 0x050c, 0x1d9c, - 0x1054, 0x2830, 0x3478, 0x040c, 0x1c9c, - 0x0f54, 0x2730, 0x3378, 0x030c, 0x1b9c, - 0x0f58, 0x2734, 0x337c, 0x0310, 0x1ba0, - 0x1058, 0x2834, 0x347c, 0x0410, 0x1ca0, - 0x1158, 0x2934, 0x357c, 0x0510, 0x1da0, - 0x115c, 0x2938, 0x3580, 0x0514, 0x1da4, - 0x105c, 0x2838, 0x3480, 0x0414, 0x1ca4, - 0x0f5c, 0x2738, 0x3380, 0x0314, 0x1ba4, - 0x0f60, 0x273c, 0x3384, 0x0318, 0x1ba8, - 0x1060, 0x283c, 0x3484, 0x0418, 0x1ca8, - 0x1160, 0x293c, 0x3584, 0x0518, 0x1da8, - 0x1164, 0x2940, 0x3588, 0x051c, 0x1dac, - 0x1064, 0x2840, 0x3488, 0x041c, 0x1cac, - 0x0f64, 0x2740, 0x3388, 0x031c, 0x1bac, - 0x0f68, 0x2744, 0x338c, 0x0320, 0x1bb0, - 0x1068, 0x2844, 0x348c, 0x0420, 0x1cb0, - 0x1168, 0x2944, 0x358c, 0x0520, 0x1db0, - 0x1548, 0x2d24, 0x396c, 0x0900, 0x2190, - 0x1648, 0x2e24, 0x3a6c, 0x0a00, 0x2290, - 0x1748, 0x2f24, 0x3b6c, 0x0b00, 0x2390, - 0x174c, 0x2f28, 0x3b70, 0x0b04, 0x2394, - 0x164c, 0x2e28, 0x3a70, 0x0a04, 0x2294, - 0x154c, 0x2d28, 0x3970, 0x0904, 0x2194, - 0x1550, 0x2d2c, 0x3974, 0x0908, 0x2198, - 0x1650, 0x2e2c, 0x3a74, 0x0a08, 0x2298, - 0x1750, 0x2f2c, 0x3b74, 0x0b08, 0x2398, - 0x1754, 0x2f30, 0x3b78, 0x0b0c, 0x239c, - 0x1654, 0x2e30, 0x3a78, 0x0a0c, 0x229c, - 0x1554, 0x2d30, 0x3978, 0x090c, 0x219c, - 0x1558, 0x2d34, 0x397c, 0x0910, 0x21a0, - 0x1658, 0x2e34, 0x3a7c, 0x0a10, 0x22a0, - 0x1758, 0x2f34, 0x3b7c, 0x0b10, 0x23a0, - 0x175c, 0x2f38, 0x3b80, 0x0b14, 0x23a4, - 0x165c, 0x2e38, 0x3a80, 0x0a14, 0x22a4, - 0x155c, 0x2d38, 0x3980, 0x0914, 0x21a4, - 0x1560, 0x2d3c, 0x3984, 0x0918, 0x21a8, - 0x1660, 0x2e3c, 0x3a84, 0x0a18, 0x22a8, - 0x1760, 0x2f3c, 0x3b84, 0x0b18, 0x23a8, - 0x1764, 0x2f40, 0x3b88, 0x0b1c, 0x23ac, - 0x1664, 0x2e40, 0x3a88, 0x0a1c, 0x22ac, - 0x1564, 0x2d40, 0x3988, 0x091c, 0x21ac, - 0x1568, 0x2d44, 0x398c, 0x0920, 0x21b0, - 0x1668, 0x2e44, 0x3a8c, 0x0a20, 0x22b0, - 0x1768, 0x2f44, 0x3b8c, 0x0b20, 0x23b0, - 0x1b48, 0x3324, 0x3f6c, 0x0f00, 0x2790, - 0x1c48, 0x3424, 0x406c, 0x1000, 0x2890, - 0x1d48, 0x3524, 0x416c, 0x1100, 0x2990, - 0x1d4c, 0x3528, 0x4170, 0x1104, 0x2994, - 0x1c4c, 0x3428, 0x4070, 0x1004, 0x2894, - 0x1b4c, 0x3328, 0x3f70, 0x0f04, 0x2794, - 0x1b50, 0x332c, 0x3f74, 0x0f08, 0x2798, - 0x1c50, 0x342c, 0x4074, 0x1008, 0x2898, - 0x1d50, 0x352c, 0x4174, 0x1108, 0x2998, - 0x1d54, 0x3530, 0x4178, 0x110c, 0x299c, - 0x1c54, 0x3430, 0x4078, 0x100c, 0x289c, - 0x1b54, 0x3330, 0x3f78, 0x0f0c, 0x279c, - 0x1b58, 0x3334, 0x3f7c, 0x0f10, 0x27a0, - 0x1c58, 0x3434, 0x407c, 0x1010, 0x28a0, - 0x1d58, 0x3534, 0x417c, 0x1110, 0x29a0, - 0x1d5c, 0x3538, 0x4180, 0x1114, 0x29a4, - 0x1c5c, 0x3438, 0x4080, 0x1014, 0x28a4, - 0x1b5c, 0x3338, 0x3f80, 0x0f14, 0x27a4, - 0x1b60, 0x333c, 0x3f84, 0x0f18, 0x27a8, - 0x1c60, 0x343c, 0x4084, 0x1018, 0x28a8, - 0x1d60, 0x353c, 0x4184, 0x1118, 0x29a8, - 0x1d64, 0x3540, 0x4188, 0x111c, 0x29ac, - 0x1c64, 0x3440, 0x4088, 0x101c, 0x28ac, - 0x1b64, 0x3340, 0x3f88, 0x0f1c, 0x27ac, - 0x1b68, 0x3344, 0x3f8c, 0x0f20, 0x27b0, - 0x1c68, 0x3444, 0x408c, 0x1020, 0x28b0, - 0x1d68, 0x3544, 0x418c, 0x1120, 0x29b0, - 0x2148, 0x3924, 0x456c, 0x1500, 0x2d90, - 0x2248, 0x3a24, 0x466c, 0x1600, 0x2e90, - 0x2348, 0x3b24, 0x476c, 0x1700, 0x2f90, - 0x234c, 0x3b28, 0x4770, 0x1704, 0x2f94, - 0x224c, 0x3a28, 0x4670, 0x1604, 0x2e94, - 0x214c, 0x3928, 0x4570, 0x1504, 0x2d94, - 0x2150, 0x392c, 0x4574, 0x1508, 0x2d98, - 0x2250, 0x3a2c, 0x4674, 0x1608, 0x2e98, - 0x2350, 0x3b2c, 0x4774, 0x1708, 0x2f98, - 0x2354, 0x3b30, 0x4778, 0x170c, 0x2f9c, - 0x2254, 0x3a30, 0x4678, 0x160c, 0x2e9c, - 0x2154, 0x3930, 0x4578, 0x150c, 0x2d9c, - 0x2158, 0x3934, 0x457c, 0x1510, 0x2da0, - 0x2258, 0x3a34, 0x467c, 0x1610, 0x2ea0, - 0x2358, 0x3b34, 0x477c, 0x1710, 0x2fa0, - 0x235c, 0x3b38, 0x4780, 0x1714, 0x2fa4, - 0x225c, 0x3a38, 0x4680, 0x1614, 0x2ea4, - 0x215c, 0x3938, 0x4580, 0x1514, 0x2da4, - 0x2160, 0x393c, 0x4584, 0x1518, 0x2da8, - 0x2260, 0x3a3c, 0x4684, 0x1618, 0x2ea8, - 0x2360, 0x3b3c, 0x4784, 0x1718, 0x2fa8, - 0x2364, 0x3b40, 0x4788, 0x171c, 0x2fac, - 0x2264, 0x3a40, 0x4688, 0x161c, 0x2eac, - 0x2164, 0x3940, 0x4588, 0x151c, 0x2dac, - 0x2168, 0x3944, 0x458c, 0x1520, 0x2db0, - 0x2268, 0x3a44, 0x468c, 0x1620, 0x2eb0, - 0x2368, 0x3b44, 0x478c, 0x1720, 0x2fb0, - 0x2748, 0x3f24, 0x036c, 0x1b00, 0x3390, - 0x2848, 0x4024, 0x046c, 0x1c00, 0x3490, - 0x2948, 0x4124, 0x056c, 0x1d00, 0x3590, - 0x294c, 0x4128, 0x0570, 0x1d04, 0x3594, - 0x284c, 0x4028, 0x0470, 0x1c04, 0x3494, - 0x274c, 0x3f28, 0x0370, 0x1b04, 0x3394, - 0x2750, 0x3f2c, 0x0374, 0x1b08, 0x3398, - 0x2850, 0x402c, 0x0474, 0x1c08, 0x3498, - 0x2950, 0x412c, 0x0574, 0x1d08, 0x3598, - 0x2954, 0x4130, 0x0578, 0x1d0c, 0x359c, - 0x2854, 0x4030, 0x0478, 0x1c0c, 0x349c, - 0x2754, 0x3f30, 0x0378, 0x1b0c, 0x339c, - 0x2758, 0x3f34, 0x037c, 0x1b10, 0x33a0, - 0x2858, 0x4034, 0x047c, 0x1c10, 0x34a0, - 0x2958, 0x4134, 0x057c, 0x1d10, 0x35a0, - 0x295c, 0x4138, 0x0580, 0x1d14, 0x35a4, - 0x285c, 0x4038, 0x0480, 0x1c14, 0x34a4, - 0x275c, 0x3f38, 0x0380, 0x1b14, 0x33a4, - 0x2760, 0x3f3c, 0x0384, 0x1b18, 0x33a8, - 0x2860, 0x403c, 0x0484, 0x1c18, 0x34a8, - 0x2960, 0x413c, 0x0584, 0x1d18, 0x35a8, - 0x2964, 0x4140, 0x0588, 0x1d1c, 0x35ac, - 0x2864, 0x4040, 0x0488, 0x1c1c, 0x34ac, - 0x2764, 0x3f40, 0x0388, 0x1b1c, 0x33ac, - 0x2768, 0x3f44, 0x038c, 0x1b20, 0x33b0, - 0x2868, 0x4044, 0x048c, 0x1c20, 0x34b0, - 0x2968, 0x4144, 0x058c, 0x1d20, 0x35b0, - 0x2d48, 0x4524, 0x096c, 0x2100, 0x3990, - 0x2e48, 0x4624, 0x0a6c, 0x2200, 0x3a90, - 0x2f48, 0x4724, 0x0b6c, 0x2300, 0x3b90, - 0x2f4c, 0x4728, 0x0b70, 0x2304, 0x3b94, - 0x2e4c, 0x4628, 0x0a70, 0x2204, 0x3a94, - 0x2d4c, 0x4528, 0x0970, 0x2104, 0x3994, - 0x2d50, 0x452c, 0x0974, 0x2108, 0x3998, - 0x2e50, 0x462c, 0x0a74, 0x2208, 0x3a98, - 0x2f50, 0x472c, 0x0b74, 0x2308, 0x3b98, - 0x2f54, 0x4730, 0x0b78, 0x230c, 0x3b9c, - 0x2e54, 0x4630, 0x0a78, 0x220c, 0x3a9c, - 0x2d54, 0x4530, 0x0978, 0x210c, 0x399c, - 0x2d58, 0x4534, 0x097c, 0x2110, 0x39a0, - 0x2e58, 0x4634, 0x0a7c, 0x2210, 0x3aa0, - 0x2f58, 0x4734, 0x0b7c, 0x2310, 0x3ba0, - 0x2f5c, 0x4738, 0x0b80, 0x2314, 0x3ba4, - 0x2e5c, 0x4638, 0x0a80, 0x2214, 0x3aa4, - 0x2d5c, 0x4538, 0x0980, 0x2114, 0x39a4, - 0x2d60, 0x453c, 0x0984, 0x2118, 0x39a8, - 0x2e60, 0x463c, 0x0a84, 0x2218, 0x3aa8, - 0x2f60, 0x473c, 0x0b84, 0x2318, 0x3ba8, - 0x2f64, 0x4740, 0x0b88, 0x231c, 0x3bac, - 0x2e64, 0x4640, 0x0a88, 0x221c, 0x3aac, - 0x2d64, 0x4540, 0x0988, 0x211c, 0x39ac, - 0x2d68, 0x4544, 0x098c, 0x2120, 0x39b0, - 0x2e68, 0x4644, 0x0a8c, 0x2220, 0x3ab0, - 0x2f68, 0x4744, 0x0b8c, 0x2320, 0x3bb0, - 0x3348, 0x0324, 0x0f6c, 0x2700, 0x3f90, - 0x3448, 0x0424, 0x106c, 0x2800, 0x4090, - 0x3548, 0x0524, 0x116c, 0x2900, 0x4190, - 0x354c, 0x0528, 0x1170, 0x2904, 0x4194, - 0x344c, 0x0428, 0x1070, 0x2804, 0x4094, - 0x334c, 0x0328, 0x0f70, 0x2704, 0x3f94, - 0x3350, 0x032c, 0x0f74, 0x2708, 0x3f98, - 0x3450, 0x042c, 0x1074, 0x2808, 0x4098, - 0x3550, 0x052c, 0x1174, 0x2908, 0x4198, - 0x3554, 0x0530, 0x1178, 0x290c, 0x419c, - 0x3454, 0x0430, 0x1078, 0x280c, 0x409c, - 0x3354, 0x0330, 0x0f78, 0x270c, 0x3f9c, - 0x3358, 0x0334, 0x0f7c, 0x2710, 0x3fa0, - 0x3458, 0x0434, 0x107c, 0x2810, 0x40a0, - 0x3558, 0x0534, 0x117c, 0x2910, 0x41a0, - 0x355c, 0x0538, 0x1180, 0x2914, 0x41a4, - 0x345c, 0x0438, 0x1080, 0x2814, 0x40a4, - 0x335c, 0x0338, 0x0f80, 0x2714, 0x3fa4, - 0x3360, 0x033c, 0x0f84, 0x2718, 0x3fa8, - 0x3460, 0x043c, 0x1084, 0x2818, 0x40a8, - 0x3560, 0x053c, 0x1184, 0x2918, 0x41a8, - 0x3564, 0x0540, 0x1188, 0x291c, 0x41ac, - 0x3464, 0x0440, 0x1088, 0x281c, 0x40ac, - 0x3364, 0x0340, 0x0f88, 0x271c, 0x3fac, - 0x3368, 0x0344, 0x0f8c, 0x2720, 0x3fb0, - 0x3468, 0x0444, 0x108c, 0x2820, 0x40b0, - 0x3568, 0x0544, 0x118c, 0x2920, 0x41b0, - 0x3948, 0x0924, 0x156c, 0x2d00, 0x4590, - 0x3a48, 0x0a24, 0x166c, 0x2e00, 0x4690, - 0x3b48, 0x0b24, 0x176c, 0x2f00, 0x4790, - 0x3b4c, 0x0b28, 0x1770, 0x2f04, 0x4794, - 0x3a4c, 0x0a28, 0x1670, 0x2e04, 0x4694, - 0x394c, 0x0928, 0x1570, 0x2d04, 0x4594, - 0x3950, 0x092c, 0x1574, 0x2d08, 0x4598, - 0x3a50, 0x0a2c, 0x1674, 0x2e08, 0x4698, - 0x3b50, 0x0b2c, 0x1774, 0x2f08, 0x4798, - 0x3b54, 0x0b30, 0x1778, 0x2f0c, 0x479c, - 0x3a54, 0x0a30, 0x1678, 0x2e0c, 0x469c, - 0x3954, 0x0930, 0x1578, 0x2d0c, 0x459c, - 0x3958, 0x0934, 0x157c, 0x2d10, 0x45a0, - 0x3a58, 0x0a34, 0x167c, 0x2e10, 0x46a0, - 0x3b58, 0x0b34, 0x177c, 0x2f10, 0x47a0, - 0x3b5c, 0x0b38, 0x1780, 0x2f14, 0x47a4, - 0x3a5c, 0x0a38, 0x1680, 0x2e14, 0x46a4, - 0x395c, 0x0938, 0x1580, 0x2d14, 0x45a4, - 0x3960, 0x093c, 0x1584, 0x2d18, 0x45a8, - 0x3a60, 0x0a3c, 0x1684, 0x2e18, 0x46a8, - 0x3b60, 0x0b3c, 0x1784, 0x2f18, 0x47a8, - 0x3b64, 0x0b40, 0x1788, 0x2f1c, 0x47ac, - 0x3a64, 0x0a40, 0x1688, 0x2e1c, 0x46ac, - 0x3964, 0x0940, 0x1588, 0x2d1c, 0x45ac, - 0x3968, 0x0944, 0x158c, 0x2d20, 0x45b0, - 0x3a68, 0x0a44, 0x168c, 0x2e20, 0x46b0, - 0x3b68, 0x0b44, 0x178c, 0x2f20, 0x47b0, - 0x3f48, 0x0f24, 0x1b6c, 0x3300, 0x0390, - 0x4048, 0x1024, 0x1c6c, 0x3400, 0x0490, - 0x4148, 0x1124, 0x1d6c, 0x3500, 0x0590, - 0x414c, 0x1128, 0x1d70, 0x3504, 0x0594, - 0x404c, 0x1028, 0x1c70, 0x3404, 0x0494, - 0x3f4c, 0x0f28, 0x1b70, 0x3304, 0x0394, - 0x3f50, 0x0f2c, 0x1b74, 0x3308, 0x0398, - 0x4050, 0x102c, 0x1c74, 0x3408, 0x0498, - 0x4150, 0x112c, 0x1d74, 0x3508, 0x0598, - 0x4154, 0x1130, 0x1d78, 0x350c, 0x059c, - 0x4054, 0x1030, 0x1c78, 0x340c, 0x049c, - 0x3f54, 0x0f30, 0x1b78, 0x330c, 0x039c, - 0x3f58, 0x0f34, 0x1b7c, 0x3310, 0x03a0, - 0x4058, 0x1034, 0x1c7c, 0x3410, 0x04a0, - 0x4158, 0x1134, 0x1d7c, 0x3510, 0x05a0, - 0x415c, 0x1138, 0x1d80, 0x3514, 0x05a4, - 0x405c, 0x1038, 0x1c80, 0x3414, 0x04a4, - 0x3f5c, 0x0f38, 0x1b80, 0x3314, 0x03a4, - 0x3f60, 0x0f3c, 0x1b84, 0x3318, 0x03a8, - 0x4060, 0x103c, 0x1c84, 0x3418, 0x04a8, - 0x4160, 0x113c, 0x1d84, 0x3518, 0x05a8, - 0x4164, 0x1140, 0x1d88, 0x351c, 0x05ac, - 0x4064, 0x1040, 0x1c88, 0x341c, 0x04ac, - 0x3f64, 0x0f40, 0x1b88, 0x331c, 0x03ac, - 0x3f68, 0x0f44, 0x1b8c, 0x3320, 0x03b0, - 0x4068, 0x1044, 0x1c8c, 0x3420, 0x04b0, - 0x4168, 0x1144, 0x1d8c, 0x3520, 0x05b0, - 0x4548, 0x1524, 0x216c, 0x3900, 0x0990, - 0x4648, 0x1624, 0x226c, 0x3a00, 0x0a90, - 0x4748, 0x1724, 0x236c, 0x3b00, 0x0b90, - 0x474c, 0x1728, 0x2370, 0x3b04, 0x0b94, - 0x464c, 0x1628, 0x2270, 0x3a04, 0x0a94, - 0x454c, 0x1528, 0x2170, 0x3904, 0x0994, - 0x4550, 0x152c, 0x2174, 0x3908, 0x0998, - 0x4650, 0x162c, 0x2274, 0x3a08, 0x0a98, - 0x4750, 0x172c, 0x2374, 0x3b08, 0x0b98, - 0x4754, 0x1730, 0x2378, 0x3b0c, 0x0b9c, - 0x4654, 0x1630, 0x2278, 0x3a0c, 0x0a9c, - 0x4554, 0x1530, 0x2178, 0x390c, 0x099c, - 0x4558, 0x1534, 0x217c, 0x3910, 0x09a0, - 0x4658, 0x1634, 0x227c, 0x3a10, 0x0aa0, - 0x4758, 0x1734, 0x237c, 0x3b10, 0x0ba0, - 0x475c, 0x1738, 0x2380, 0x3b14, 0x0ba4, - 0x465c, 0x1638, 0x2280, 0x3a14, 0x0aa4, - 0x455c, 0x1538, 0x2180, 0x3914, 0x09a4, - 0x4560, 0x153c, 0x2184, 0x3918, 0x09a8, - 0x4660, 0x163c, 0x2284, 0x3a18, 0x0aa8, - 0x4760, 0x173c, 0x2384, 0x3b18, 0x0ba8, - 0x4764, 0x1740, 0x2388, 0x3b1c, 0x0bac, - 0x4664, 0x1640, 0x2288, 0x3a1c, 0x0aac, - 0x4564, 0x1540, 0x2188, 0x391c, 0x09ac, - 0x4568, 0x1544, 0x218c, 0x3920, 0x09b0, - 0x4668, 0x1644, 0x228c, 0x3a20, 0x0ab0, - 0x4768, 0x1744, 0x238c, 0x3b20, 0x0bb0, - 0x0348, 0x1b24, 0x276c, 0x3f00, 0x0f90, - 0x0448, 0x1c24, 0x286c, 0x4000, 0x1090, - 0x0548, 0x1d24, 0x296c, 0x4100, 0x1190, - 0x054c, 0x1d28, 0x2970, 0x4104, 0x1194, - 0x044c, 0x1c28, 0x2870, 0x4004, 0x1094, - 0x034c, 0x1b28, 0x2770, 0x3f04, 0x0f94, - 0x0350, 0x1b2c, 0x2774, 0x3f08, 0x0f98, - 0x0450, 0x1c2c, 0x2874, 0x4008, 0x1098, - 0x0550, 0x1d2c, 0x2974, 0x4108, 0x1198, - 0x0554, 0x1d30, 0x2978, 0x410c, 0x119c, - 0x0454, 0x1c30, 0x2878, 0x400c, 0x109c, - 0x0354, 0x1b30, 0x2778, 0x3f0c, 0x0f9c, - 0x0358, 0x1b34, 0x277c, 0x3f10, 0x0fa0, - 0x0458, 0x1c34, 0x287c, 0x4010, 0x10a0, - 0x0558, 0x1d34, 0x297c, 0x4110, 0x11a0, - 0x055c, 0x1d38, 0x2980, 0x4114, 0x11a4, - 0x045c, 0x1c38, 0x2880, 0x4014, 0x10a4, - 0x035c, 0x1b38, 0x2780, 0x3f14, 0x0fa4, - 0x0360, 0x1b3c, 0x2784, 0x3f18, 0x0fa8, - 0x0460, 0x1c3c, 0x2884, 0x4018, 0x10a8, - 0x0560, 0x1d3c, 0x2984, 0x4118, 0x11a8, - 0x0564, 0x1d40, 0x2988, 0x411c, 0x11ac, - 0x0464, 0x1c40, 0x2888, 0x401c, 0x10ac, - 0x0364, 0x1b40, 0x2788, 0x3f1c, 0x0fac, - 0x0368, 0x1b44, 0x278c, 0x3f20, 0x0fb0, - 0x0468, 0x1c44, 0x288c, 0x4020, 0x10b0, - 0x0568, 0x1d44, 0x298c, 0x4120, 0x11b0, - 0x0948, 0x2124, 0x2d6c, 0x4500, 0x1590, - 0x0a48, 0x2224, 0x2e6c, 0x4600, 0x1690, - 0x0b48, 0x2324, 0x2f6c, 0x4700, 0x1790, - 0x0b4c, 0x2328, 0x2f70, 0x4704, 0x1794, - 0x0a4c, 0x2228, 0x2e70, 0x4604, 0x1694, - 0x094c, 0x2128, 0x2d70, 0x4504, 0x1594, - 0x0950, 0x212c, 0x2d74, 0x4508, 0x1598, - 0x0a50, 0x222c, 0x2e74, 0x4608, 0x1698, - 0x0b50, 0x232c, 0x2f74, 0x4708, 0x1798, - 0x0b54, 0x2330, 0x2f78, 0x470c, 0x179c, - 0x0a54, 0x2230, 0x2e78, 0x460c, 0x169c, - 0x0954, 0x2130, 0x2d78, 0x450c, 0x159c, - 0x0958, 0x2134, 0x2d7c, 0x4510, 0x15a0, - 0x0a58, 0x2234, 0x2e7c, 0x4610, 0x16a0, - 0x0b58, 0x2334, 0x2f7c, 0x4710, 0x17a0, - 0x0b5c, 0x2338, 0x2f80, 0x4714, 0x17a4, - 0x0a5c, 0x2238, 0x2e80, 0x4614, 0x16a4, - 0x095c, 0x2138, 0x2d80, 0x4514, 0x15a4, - 0x0960, 0x213c, 0x2d84, 0x4518, 0x15a8, - 0x0a60, 0x223c, 0x2e84, 0x4618, 0x16a8, - 0x0b60, 0x233c, 0x2f84, 0x4718, 0x17a8, - 0x0b64, 0x2340, 0x2f88, 0x471c, 0x17ac, - 0x0a64, 0x2240, 0x2e88, 0x461c, 0x16ac, - 0x0964, 0x2140, 0x2d88, 0x451c, 0x15ac, - 0x0968, 0x2144, 0x2d8c, 0x4520, 0x15b0, - 0x0a68, 0x2244, 0x2e8c, 0x4620, 0x16b0, - 0x0b68, 0x2344, 0x2f8c, 0x4720, 0x17b0, -}; - -/* DV25/50 DCT coefficient weights and inverse weights */ -/* created by dvtables.py */ -static const int dv_weight_bits = 18; -static const int dv_weight_88[64] = { - 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536, - 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935, - 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916, - 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433, - 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704, - 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568, - 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627, - 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258, -}; -static const int dv_weight_248[64] = { - 131072, 242189, 257107, 237536, 229376, 200636, 242189, 223754, - 224969, 196781, 262144, 242189, 229376, 200636, 257107, 237536, - 211916, 185364, 235923, 217965, 229376, 211916, 206433, 180568, - 242189, 223754, 224969, 196781, 211916, 185364, 235923, 217965, - 200704, 175557, 222935, 205965, 200636, 185364, 195068, 170627, - 229376, 211916, 206433, 180568, 200704, 175557, 222935, 205965, - 175557, 153560, 188995, 174609, 165371, 144651, 200636, 185364, - 195068, 170627, 175557, 153560, 188995, 174609, 165371, 144651, -}; -static const int dv_iweight_bits = 14; -static const int dv_iweight_88[64] = { - 32768, 16710, 16710, 17735, 17015, 17735, 18197, 18079, - 18079, 18197, 18725, 18559, 19196, 18559, 18725, 19284, - 19108, 19692, 19692, 19108, 19284, 21400, 19645, 20262, - 20214, 20262, 19645, 21400, 22733, 21845, 20867, 20815, - 20815, 20867, 21845, 22733, 23173, 23173, 21400, 21400, - 21400, 23173, 23173, 24600, 23764, 22017, 22017, 23764, - 24600, 25267, 24457, 22672, 24457, 25267, 25971, 25191, - 25191, 25971, 26715, 27962, 26715, 29642, 29642, 31536, -}; -static const int dv_iweight_248[64] = { - 32768, 17735, 16710, 18079, 18725, 21400, 17735, 19196, - 19108, 21845, 16384, 17735, 18725, 21400, 16710, 18079, - 20262, 23173, 18197, 19692, 18725, 20262, 20815, 23764, - 17735, 19196, 19108, 21845, 20262, 23173, 18197, 19692, - 21400, 24457, 19284, 20867, 21400, 23173, 22017, 25191, - 18725, 20262, 20815, 23764, 21400, 24457, 19284, 20867, - 24457, 27962, 22733, 24600, 25971, 29642, 21400, 23173, - 22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642, -}; - -static const uint16_t dv_audio_shuffle525[10][9] = { - { 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */ - { 6, 36, 66, 26, 56, 86, 16, 46, 76 }, - { 12, 42, 72, 2, 32, 62, 22, 52, 82 }, - { 18, 48, 78, 8, 38, 68, 28, 58, 88 }, - { 24, 54, 84, 14, 44, 74, 4, 34, 64 }, - - { 1, 31, 61, 21, 51, 81, 11, 41, 71 }, /* 2nd channel */ - { 7, 37, 67, 27, 57, 87, 17, 47, 77 }, - { 13, 43, 73, 3, 33, 63, 23, 53, 83 }, - { 19, 49, 79, 9, 39, 69, 29, 59, 89 }, - { 25, 55, 85, 15, 45, 75, 5, 35, 65 }, -}; - -static const uint16_t dv_audio_shuffle625[12][9] = { - { 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */ - { 6, 42, 78, 32, 68, 104, 22, 58, 94}, - { 12, 48, 84, 2, 38, 74, 28, 64, 100}, - { 18, 54, 90, 8, 44, 80, 34, 70, 106}, - { 24, 60, 96, 14, 50, 86, 4, 40, 76}, - { 30, 66, 102, 20, 56, 92, 10, 46, 82}, - - { 1, 37, 73, 27, 63, 99, 17, 53, 89}, /* 2nd channel */ - { 7, 43, 79, 33, 69, 105, 23, 59, 95}, - { 13, 49, 85, 3, 39, 75, 29, 65, 101}, - { 19, 55, 91, 9, 45, 81, 35, 71, 107}, - { 25, 61, 97, 15, 51, 87, 5, 41, 77}, - { 31, 67, 103, 21, 57, 93, 11, 47, 83}, -}; - -static const __attribute__((unused)) int dv_audio_frequency[3] = { - 48000, 44100, 32000, -}; - -static const DVprofile dv_profiles[] = { - { .dsf = 0, - .frame_size = 120000, /* IEC 61834, SMPTE-314M - 525/60 (NTSC) */ - .difseg_size = 10, - .n_difchan = 1, - .frame_rate = 30000, - .ltc_divisor = 30, - .frame_rate_base = 1001, - .height = 480, - .width = 720, - .sar = {{10, 11}, {40, 33}}, - .video_place = dv_place_411, - .pix_fmt = PIX_FMT_YUV411P, - .audio_stride = 90, - .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32Khz */ - .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */ - .audio_shuffle = dv_audio_shuffle525, - }, - { .dsf = 1, - .frame_size = 144000, /* IEC 61834 - 625/50 (PAL) */ - .difseg_size = 12, - .n_difchan = 1, - .frame_rate = 25, - .frame_rate_base = 1, - .ltc_divisor = 25, - .height = 576, - .width = 720, - .sar = {{59, 54}, {118, 81}}, - .video_place = dv_place_420, - .pix_fmt = PIX_FMT_YUV420P, - .audio_stride = 108, - .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */ - .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, - .audio_shuffle = dv_audio_shuffle625, - }, - { .dsf = 1, - .frame_size = 144000, /* SMPTE-314M - 625/50 (PAL) */ - .difseg_size = 12, - .n_difchan = 1, - .frame_rate = 25, - .frame_rate_base = 1, - .ltc_divisor = 25, - .height = 576, - .width = 720, - .sar = {{59, 54}, {118, 81}}, - .video_place = dv_place_411P, - .pix_fmt = PIX_FMT_YUV411P, - .audio_stride = 108, - .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */ - .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, - .audio_shuffle = dv_audio_shuffle625, - }, - { .dsf = 0, - .frame_size = 240000, /* SMPTE-314M - 525/60 (NTSC) 50 Mbps */ - .difseg_size = 10, /* also known as "DVCPRO50" */ - .n_difchan = 2, - .frame_rate = 30000, - .ltc_divisor = 30, - .frame_rate_base = 1001, - .height = 480, - .width = 720, - .sar = {{10, 11}, {40, 33}}, - .video_place = dv_place_422_525, - .pix_fmt = PIX_FMT_YUV422P, - .audio_stride = 90, - .audio_min_samples = { 1580, 1452, 1053 }, /* for 48, 44.1 and 32Khz */ - .audio_samples_dist = { 1600, 1602, 1602, 1602, 1602 }, /* per SMPTE-314M */ - .audio_shuffle = dv_audio_shuffle525, - }, - { .dsf = 1, - .frame_size = 288000, /* SMPTE-314M - 625/50 (PAL) 50 Mbps */ - .difseg_size = 12, /* also known as "DVCPRO50" */ - .n_difchan = 2, - .frame_rate = 25, - .frame_rate_base = 1, - .ltc_divisor = 25, - .height = 576, - .width = 720, - .sar = {{59, 54}, {118, 81}}, - .video_place = dv_place_422_625, - .pix_fmt = PIX_FMT_YUV422P, - .audio_stride = 108, - .audio_min_samples = { 1896, 1742, 1264 }, /* for 48, 44.1 and 32Khz */ - .audio_samples_dist = { 1920, 1920, 1920, 1920, 1920 }, - .audio_shuffle = dv_audio_shuffle625, - } -}; - -enum dv_section_type { - dv_sect_header = 0x1f, - dv_sect_subcode = 0x3f, - dv_sect_vaux = 0x56, - dv_sect_audio = 0x76, - dv_sect_video = 0x96, -}; - -enum dv_pack_type { - dv_header525 = 0x3f, /* see dv_write_pack for important details on */ - dv_header625 = 0xbf, /* these two packs */ - dv_timecode = 0x13, - dv_audio_source = 0x50, - dv_audio_control = 0x51, - dv_audio_recdate = 0x52, - dv_audio_rectime = 0x53, - dv_video_source = 0x60, - dv_video_control = 0x61, - dv_video_recdate = 0x62, - dv_video_rectime = 0x63, - dv_unknown_pack = 0xff, -}; - -/* minimum number of bytes to read from a DV stream in order to determine the profile */ -#define DV_PROFILE_BYTES (6*80) /* 6 DIF blocks */ - -/* largest possible DV frame, in bytes (PAL 50Mbps) */ -#define DV_MAX_FRAME_SIZE 288000 - -static inline const DVprofile* dv_frame_profile(uint8_t* frame) -{ - if ((frame[3] & 0x80) == 0) { /* DSF flag */ - /* it's an NTSC format */ - if ((frame[80*5 + 48 + 3] & 0x4)) { /* 4:2:2 sampling */ - return &dv_profiles[3]; /* NTSC 50Mbps */ - } else { /* 4:1:1 sampling */ - return &dv_profiles[0]; /* NTSC 25Mbps */ - } - } else { - /* it's a PAL format */ - if ((frame[80*5 + 48 + 3] & 0x4)) { /* 4:2:2 sampling */ - return &dv_profiles[4]; /* PAL 50Mbps */ - } else if ((frame[5] & 0x07) == 0) { /* APT flag */ - return &dv_profiles[1]; /* PAL 25Mbps 4:2:0 */ - } else - return &dv_profiles[2]; /* PAL 25Mbps 4:1:1 */ - } -} - -static inline const DVprofile* dv_codec_profile(AVCodecContext* codec) -{ - int i; - - if (codec->width != 720) - return NULL; - - for (i=0; i<sizeof(dv_profiles)/sizeof(DVprofile); i++) - if (codec->height == dv_profiles[i].height && codec->pix_fmt == dv_profiles[i].pix_fmt) - return &dv_profiles[i]; - - return NULL; -} - -static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, uint8_t seq_num, - uint8_t dif_num, uint8_t* buf) -{ - buf[0] = (uint8_t)t; /* Section type */ - buf[1] = (seq_num<<4) | /* DIF seq number 0-9 for 525/60; 0-11 for 625/50 */ - (chan_num << 3) | /* FSC: for 50Mb/s 0 - first channel; 1 - second */ - 7; /* reserved -- always 1 */ - buf[2] = dif_num; /* DIF block number Video: 0-134, Audio: 0-8 */ - return 3; -} - - -static inline int dv_write_ssyb_id(uint8_t syb_num, uint8_t fr, uint8_t* buf) -{ - if (syb_num == 0 || syb_num == 6) { - buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ - (0<<4) | /* AP3 (Subcode application ID) */ - 0x0f; /* reserved -- always 1 */ - } - else if (syb_num == 11) { - buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ - 0x7f; /* reserved -- always 1 */ - } - else { - buf[0] = (fr<<7) | /* FR ID 1 - first half of each channel; 0 - second */ - (0<<4) | /* APT (Track application ID) */ - 0x0f; /* reserved -- always 1 */ - } - buf[1] = 0xf0 | /* reserved -- always 1 */ - (syb_num & 0x0f); /* SSYB number 0 - 11 */ - buf[2] = 0xff; /* reserved -- always 1 */ - return 3; -}
--- a/src/ffmpeg/libavcodec/dvdsub.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,477 +0,0 @@ -/* - * DVD subtitle decoding for ffmpeg - * Copyright (c) 2005 Fabrice Bellard. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "avcodec.h" - -//#define DEBUG - -static int dvdsub_init_decoder(AVCodecContext *avctx) -{ - return 0; -} - -static uint16_t getbe16(const uint8_t *p) -{ - return (p[0] << 8) | p[1]; -} - -static int get_nibble(const uint8_t *buf, int nibble_offset) -{ - return (buf[nibble_offset >> 1] >> ((1 - (nibble_offset & 1)) << 2)) & 0xf; -} - -static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, - const uint8_t *buf, int nibble_offset, int buf_size) -{ - unsigned int v; - int x, y, len, color, nibble_end; - uint8_t *d; - - nibble_end = buf_size * 2; - x = 0; - y = 0; - d = bitmap; - for(;;) { - if (nibble_offset >= nibble_end) - return -1; - v = get_nibble(buf, nibble_offset++); - if (v < 0x4) { - v = (v << 4) | get_nibble(buf, nibble_offset++); - if (v < 0x10) { - v = (v << 4) | get_nibble(buf, nibble_offset++); - if (v < 0x040) { - v = (v << 4) | get_nibble(buf, nibble_offset++); - if (v < 4) { - v |= (w - x) << 2; - } - } - } - } - len = v >> 2; - if (len > (w - x)) - len = (w - x); - color = v & 0x03; - memset(d + x, color, len); - x += len; - if (x >= w) { - y++; - if (y >= h) - break; - d += linesize; - x = 0; - /* byte align */ - nibble_offset += (nibble_offset & 1); - } - } - return 0; -} - -static void guess_palette(uint32_t *rgba_palette, - uint8_t *palette, - uint8_t *alpha, - uint32_t subtitle_color) -{ - uint8_t color_used[16]; - int nb_opaque_colors, i, level, j, r, g, b; - - for(i = 0; i < 4; i++) - rgba_palette[i] = 0; - - memset(color_used, 0, 16); - nb_opaque_colors = 0; - for(i = 0; i < 4; i++) { - if (alpha[i] != 0 && !color_used[palette[i]]) { - color_used[palette[i]] = 1; - nb_opaque_colors++; - } - } - - if (nb_opaque_colors == 0) - return; - - j = nb_opaque_colors; - memset(color_used, 0, 16); - for(i = 0; i < 4; i++) { - if (alpha[i] != 0) { - if (!color_used[palette[i]]) { - level = (0xff * j) / nb_opaque_colors; - r = (((subtitle_color >> 16) & 0xff) * level) >> 8; - g = (((subtitle_color >> 8) & 0xff) * level) >> 8; - b = (((subtitle_color >> 0) & 0xff) * level) >> 8; - rgba_palette[i] = b | (g << 8) | (r << 16) | ((alpha[i] * 17) << 24); - color_used[palette[i]] = (i + 1); - j--; - } else { - rgba_palette[i] = (rgba_palette[color_used[palette[i]] - 1] & 0x00ffffff) | - ((alpha[i] * 17) << 24); - } - } - } -} - -static int decode_dvd_subtitles(AVSubtitle *sub_header, - const uint8_t *buf, int buf_size) -{ - int cmd_pos, pos, cmd, x1, y1, x2, y2, offset1, offset2, next_cmd_pos; - uint8_t palette[4], alpha[4]; - int date; - int i; - int is_menu = 0; - - if (buf_size < 4) - return -1; - sub_header->rects = NULL; - sub_header->num_rects = 0; - sub_header->start_display_time = 0; - sub_header->end_display_time = 0; - - cmd_pos = getbe16(buf + 2); - while ((cmd_pos + 4) < buf_size) { - date = getbe16(buf + cmd_pos); - next_cmd_pos = getbe16(buf + cmd_pos + 2); -#ifdef DEBUG - av_log(NULL, AV_LOG_INFO, "cmd_pos=0x%04x next=0x%04x date=%d\n", - cmd_pos, next_cmd_pos, date); -#endif - pos = cmd_pos + 4; - offset1 = -1; - offset2 = -1; - x1 = y1 = x2 = y2 = 0; - while (pos < buf_size) { - cmd = buf[pos++]; -#ifdef DEBUG - av_log(NULL, AV_LOG_INFO, "cmd=%02x\n", cmd); -#endif - switch(cmd) { - case 0x00: - /* menu subpicture */ - is_menu = 1; - break; - case 0x01: - /* set start date */ - sub_header->start_display_time = (date << 10) / 90; - break; - case 0x02: - /* set end date */ - sub_header->end_display_time = (date << 10) / 90; - break; - case 0x03: - /* set palette */ - if ((buf_size - pos) < 2) - goto fail; - palette[3] = buf[pos] >> 4; - palette[2] = buf[pos] & 0x0f; - palette[1] = buf[pos + 1] >> 4; - palette[0] = buf[pos + 1] & 0x0f; - pos += 2; - break; - case 0x04: - /* set alpha */ - if ((buf_size - pos) < 2) - goto fail; - alpha[3] = buf[pos] >> 4; - alpha[2] = buf[pos] & 0x0f; - alpha[1] = buf[pos + 1] >> 4; - alpha[0] = buf[pos + 1] & 0x0f; - pos += 2; -#ifdef DEBUG - av_log(NULL, AV_LOG_INFO, "alpha=%x%x%x%x\n", alpha[0],alpha[1],alpha[2],alpha[3]); -#endif - break; - case 0x05: - if ((buf_size - pos) < 6) - goto fail; - x1 = (buf[pos] << 4) | (buf[pos + 1] >> 4); - x2 = ((buf[pos + 1] & 0x0f) << 8) | buf[pos + 2]; - y1 = (buf[pos + 3] << 4) | (buf[pos + 4] >> 4); - y2 = ((buf[pos + 4] & 0x0f) << 8) | buf[pos + 5]; -#ifdef DEBUG - av_log(NULL, AV_LOG_INFO, "x1=%d x2=%d y1=%d y2=%d\n", - x1, x2, y1, y2); -#endif - pos += 6; - break; - case 0x06: - if ((buf_size - pos) < 4) - goto fail; - offset1 = getbe16(buf + pos); - offset2 = getbe16(buf + pos + 2); -#ifdef DEBUG - av_log(NULL, AV_LOG_INFO, "offset1=0x%04x offset2=0x%04x\n", offset1, offset2); -#endif - pos += 4; - break; - case 0xff: - default: - goto the_end; - } - } - the_end: - if (offset1 >= 0) { - int w, h; - uint8_t *bitmap; - - /* decode the bitmap */ - w = x2 - x1 + 1; - if (w < 0) - w = 0; - h = y2 - y1; - if (h < 0) - h = 0; - if (w > 0 && h > 0) { - if (sub_header->rects != NULL) { - for (i = 0; i < sub_header->num_rects; i++) { - av_free(sub_header->rects[i].bitmap); - av_free(sub_header->rects[i].rgba_palette); - } - av_freep(&sub_header->rects); - sub_header->num_rects = 0; - } - - bitmap = av_malloc(w * h); - sub_header->rects = av_mallocz(sizeof(AVSubtitleRect)); - sub_header->num_rects = 1; - sub_header->rects[0].rgba_palette = av_malloc(4 * 4); - decode_rle(bitmap, w * 2, w, h / 2, - buf, offset1 * 2, buf_size); - decode_rle(bitmap + w, w * 2, w, h / 2, - buf, offset2 * 2, buf_size); - guess_palette(sub_header->rects[0].rgba_palette, - palette, alpha, 0xffff00); - sub_header->rects[0].x = x1; - sub_header->rects[0].y = y1; - sub_header->rects[0].w = w; - sub_header->rects[0].h = h; - sub_header->rects[0].nb_colors = 4; - sub_header->rects[0].linesize = w; - sub_header->rects[0].bitmap = bitmap; - } - } - if (next_cmd_pos == cmd_pos) - break; - cmd_pos = next_cmd_pos; - } - if (sub_header->num_rects > 0) - return is_menu; - fail: - return -1; -} - -static int is_transp(const uint8_t *buf, int pitch, int n, - const uint8_t *transp_color) -{ - int i; - for(i = 0; i < n; i++) { - if (!transp_color[*buf]) - return 0; - buf += pitch; - } - return 1; -} - -/* return 0 if empty rectangle, 1 if non empty */ -static int find_smallest_bounding_rectangle(AVSubtitle *s) -{ - uint8_t transp_color[256]; - int y1, y2, x1, x2, y, w, h, i; - uint8_t *bitmap; - - if (s->num_rects == 0 || s->rects == NULL || s->rects[0].w <= 0 || s->rects[0].h <= 0) - return 0; - - memset(transp_color, 0, 256); - for(i = 0; i < s->rects[0].nb_colors; i++) { - if ((s->rects[0].rgba_palette[i] >> 24) == 0) - transp_color[i] = 1; - } - y1 = 0; - while (y1 < s->rects[0].h && is_transp(s->rects[0].bitmap + y1 * s->rects[0].linesize, - 1, s->rects[0].w, transp_color)) - y1++; - if (y1 == s->rects[0].h) { - av_freep(&s->rects[0].bitmap); - s->rects[0].w = s->rects[0].h = 0; - return 0; - } - - y2 = s->rects[0].h - 1; - while (y2 > 0 && is_transp(s->rects[0].bitmap + y2 * s->rects[0].linesize, 1, - s->rects[0].w, transp_color)) - y2--; - x1 = 0; - while (x1 < (s->rects[0].w - 1) && is_transp(s->rects[0].bitmap + x1, s->rects[0].linesize, - s->rects[0].h, transp_color)) - x1++; - x2 = s->rects[0].w - 1; - while (x2 > 0 && is_transp(s->rects[0].bitmap + x2, s->rects[0].linesize, s->rects[0].h, - transp_color)) - x2--; - w = x2 - x1 + 1; - h = y2 - y1 + 1; - bitmap = av_malloc(w * h); - if (!bitmap) - return 1; - for(y = 0; y < h; y++) { - memcpy(bitmap + w * y, s->rects[0].bitmap + x1 + (y1 + y) * s->rects[0].linesize, w); - } - av_freep(&s->rects[0].bitmap); - s->rects[0].bitmap = bitmap; - s->rects[0].linesize = w; - s->rects[0].w = w; - s->rects[0].h = h; - s->rects[0].x += x1; - s->rects[0].y += y1; - return 1; -} - -static int dvdsub_close_decoder(AVCodecContext *avctx) -{ - return 0; -} - -#ifdef DEBUG -#undef fprintf -static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h, - uint32_t *rgba_palette) -{ - int x, y, v; - FILE *f; - - f = fopen(filename, "w"); - if (!f) { - perror(filename); - exit(1); - } - fprintf(f, "P6\n" - "%d %d\n" - "%d\n", - w, h, 255); - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) { - v = rgba_palette[bitmap[y * w + x]]; - putc((v >> 16) & 0xff, f); - putc((v >> 8) & 0xff, f); - putc((v >> 0) & 0xff, f); - } - } - fclose(f); -} -#endif - -static int dvdsub_decode(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - AVSubtitle *sub = (void *)data; - int is_menu; - - is_menu = decode_dvd_subtitles(sub, buf, buf_size); - - if (is_menu < 0) { - no_subtitle: - *data_size = 0; - - return buf_size; - } - if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) - goto no_subtitle; - -#if defined(DEBUG) - av_log(NULL, AV_LOG_INFO, "start=%d ms end =%d ms\n", - sub->start_display_time, - sub->end_display_time); - ppm_save("/tmp/a.ppm", sub->rects[0].bitmap, - sub->rects[0].w, sub->rects[0].h, sub->rects[0].rgba_palette); -#endif - - *data_size = 1; - return buf_size; -} - -AVCodec dvdsub_decoder = { - "dvdsub", - CODEC_TYPE_SUBTITLE, - CODEC_ID_DVD_SUBTITLE, - 0, - dvdsub_init_decoder, - NULL, - dvdsub_close_decoder, - dvdsub_decode, -}; - -/* parser definition */ -typedef struct DVDSubParseContext { - uint8_t *packet; - int packet_len; - int packet_index; -} DVDSubParseContext; - -static int dvdsub_parse_init(AVCodecParserContext *s) -{ - return 0; -} - -static int dvdsub_parse(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size) -{ - DVDSubParseContext *pc = s->priv_data; - - if (pc->packet_index == 0) { - if (buf_size < 2) - return 0; - pc->packet_len = (buf[0] << 8) | buf[1]; - av_freep(&pc->packet); - pc->packet = av_malloc(pc->packet_len); - } - if (pc->packet) { - if (pc->packet_index + buf_size <= pc->packet_len) { - memcpy(pc->packet + pc->packet_index, buf, buf_size); - pc->packet_index += buf_size; - if (pc->packet_index >= pc->packet_len) { - *poutbuf = pc->packet; - *poutbuf_size = pc->packet_len; - pc->packet_index = 0; - return buf_size; - } - } else { - /* erroneous size */ - pc->packet_index = 0; - } - } - *poutbuf = NULL; - *poutbuf_size = 0; - return buf_size; -} - -static void dvdsub_parse_close(AVCodecParserContext *s) -{ - DVDSubParseContext *pc = s->priv_data; - av_freep(&pc->packet); -} - -AVCodecParser dvdsub_parser = { - { CODEC_ID_DVD_SUBTITLE }, - sizeof(DVDSubParseContext), - dvdsub_parse_init, - dvdsub_parse, - dvdsub_parse_close, -};
--- a/src/ffmpeg/libavcodec/dvdsubenc.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,247 +0,0 @@ -/* - * DVD subtitle encoding for ffmpeg - * Copyright (c) 2005 Wolfram Gloger. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#include "avcodec.h" - -#undef NDEBUG -#include <assert.h> - -// ncnt is the nibble counter -#define PUTNIBBLE(val)\ -do {\ - if (ncnt++ & 1)\ - *q++ = bitbuf | ((val) & 0x0f);\ - else\ - bitbuf = (val) << 4;\ -} while(0) - -static void dvd_encode_rle(uint8_t **pq, - const uint8_t *bitmap, int linesize, - int w, int h, - const int cmap[256]) -{ - uint8_t *q; - unsigned int bitbuf = 0; - int ncnt; - int x, y, len, color; - - q = *pq; - - for (y = 0; y < h; ++y) { - ncnt = 0; - for(x = 0; x < w; x += len) { - color = bitmap[x]; - for (len=1; x+len < w; ++len) - if (bitmap[x+len] != color) - break; - color = cmap[color]; - assert(color < 4); - if (len < 0x04) { - PUTNIBBLE((len << 2)|color); - } else if (len < 0x10) { - PUTNIBBLE(len >> 2); - PUTNIBBLE((len << 2)|color); - } else if (len < 0x40) { - PUTNIBBLE(0); - PUTNIBBLE(len >> 2); - PUTNIBBLE((len << 2)|color); - } else if (x+len == w) { - PUTNIBBLE(0); - PUTNIBBLE(0); - PUTNIBBLE(0); - PUTNIBBLE(color); - } else { - if (len > 0xff) - len = 0xff; - PUTNIBBLE(0); - PUTNIBBLE(len >> 6); - PUTNIBBLE(len >> 2); - PUTNIBBLE((len << 2)|color); - } - } - /* end of line */ - if (ncnt & 1) - PUTNIBBLE(0); - bitmap += linesize; - } - - *pq = q; -} - -static inline void putbe16(uint8_t **pq, uint16_t v) -{ - uint8_t *q = *pq; - *q++ = v >> 8; - *q++ = v; - *pq = q; -} - -static int encode_dvd_subtitles(uint8_t *outbuf, int outbuf_size, - const AVSubtitle *h) -{ - uint8_t *q, *qq; - int object_id; - int offset1[20], offset2[20]; - int i, imax, color, alpha, rects = h->num_rects; - unsigned long hmax; - unsigned long hist[256]; - int cmap[256]; - - if (rects == 0 || h->rects == NULL) - return -1; - if (rects > 20) - rects = 20; - - // analyze bitmaps, compress to 4 colors - for (i=0; i<256; ++i) { - hist[i] = 0; - cmap[i] = 0; - } - for (object_id = 0; object_id < rects; object_id++) - for (i=0; i<h->rects[object_id].w*h->rects[object_id].h; ++i) { - color = h->rects[object_id].bitmap[i]; - // only count non-transparent pixels - alpha = h->rects[object_id].rgba_palette[color] >> 24; - hist[color] += alpha; - } - for (color=3;; --color) { - hmax = 0; - imax = 0; - for (i=0; i<256; ++i) - if (hist[i] > hmax) { - imax = i; - hmax = hist[i]; - } - if (hmax == 0) - break; - if (color == 0) - color = 3; - av_log(NULL, AV_LOG_DEBUG, "dvd_subtitle hist[%d]=%ld -> col %d\n", - imax, hist[imax], color); - cmap[imax] = color; - hist[imax] = 0; - } - - - // encode data block - q = outbuf + 4; - for (object_id = 0; object_id < rects; object_id++) { - offset1[object_id] = q - outbuf; - // worst case memory requirement: 1 nibble per pixel.. - if ((q - outbuf) + h->rects[object_id].w*h->rects[object_id].h/2 - + 17*rects + 21 > outbuf_size) { - av_log(NULL, AV_LOG_ERROR, "dvd_subtitle too big\n"); - return -1; - } - dvd_encode_rle(&q, h->rects[object_id].bitmap, - h->rects[object_id].w*2, - h->rects[object_id].w, h->rects[object_id].h >> 1, - cmap); - offset2[object_id] = q - outbuf; - dvd_encode_rle(&q, h->rects[object_id].bitmap + h->rects[object_id].w, - h->rects[object_id].w*2, - h->rects[object_id].w, h->rects[object_id].h >> 1, - cmap); - } - - // set data packet size - qq = outbuf + 2; - putbe16(&qq, q - outbuf); - - // send start display command - putbe16(&q, (h->start_display_time*90) >> 10); - putbe16(&q, (q - outbuf) /*- 2 */ + 8 + 12*rects + 2); - *q++ = 0x03; // palette - 4 nibbles - *q++ = 0x03; *q++ = 0x7f; - *q++ = 0x04; // alpha - 4 nibbles - *q++ = 0xf0; *q++ = 0x00; - //*q++ = 0x0f; *q++ = 0xff; - - // XXX not sure if more than one rect can really be encoded.. - // 12 bytes per rect - for (object_id = 0; object_id < rects; object_id++) { - int x2 = h->rects[object_id].x + h->rects[object_id].w - 1; - int y2 = h->rects[object_id].y + h->rects[object_id].h - 1; - - *q++ = 0x05; - // x1 x2 -> 6 nibbles - *q++ = h->rects[object_id].x >> 4; - *q++ = (h->rects[object_id].x << 4) | ((x2 >> 8) & 0xf); - *q++ = x2; - // y1 y2 -> 6 nibbles - *q++ = h->rects[object_id].y >> 4; - *q++ = (h->rects[object_id].y << 4) | ((y2 >> 8) & 0xf); - *q++ = y2; - - *q++ = 0x06; - // offset1, offset2 - putbe16(&q, offset1[object_id]); - putbe16(&q, offset2[object_id]); - } - *q++ = 0x01; // start command - *q++ = 0xff; // terminating command - - // send stop display command last - putbe16(&q, (h->end_display_time*90) >> 10); - putbe16(&q, (q - outbuf) - 2 /*+ 4*/); - *q++ = 0x02; // set end - *q++ = 0xff; // terminating command - - qq = outbuf; - putbe16(&qq, q - outbuf); - - av_log(NULL, AV_LOG_DEBUG, "subtitle_packet size=%td\n", q - outbuf); - return q - outbuf; -} - -static int dvdsub_init_encoder(AVCodecContext *avctx) -{ - return 0; -} - -static int dvdsub_close_encoder(AVCodecContext *avctx) -{ - return 0; -} - -static int dvdsub_encode(AVCodecContext *avctx, - unsigned char *buf, int buf_size, void *data) -{ - //DVDSubtitleContext *s = avctx->priv_data; - AVSubtitle *sub = data; - int ret; - - ret = encode_dvd_subtitles(buf, buf_size, sub); - return ret; -} - -AVCodec dvdsub_encoder = { - "dvdsub", - CODEC_TYPE_SUBTITLE, - CODEC_ID_DVD_SUBTITLE, - 0, - dvdsub_init_encoder, - dvdsub_encode, - dvdsub_close_encoder, -}; - -/* Local Variables: */ -/* c-basic-offset:4 */ -/* End: */
--- a/src/ffmpeg/libavcodec/faac.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,133 +0,0 @@ -/* - * Interface to libfaac for aac encoding - * Copyright (c) 2002 Gildas Bazin <gbazin@netcourrier.com> - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file faacaudio.c - * Interface to libfaac for aac encoding. - */ - -#include "avcodec.h" -#include <faac.h> - -typedef struct FaacAudioContext { - faacEncHandle faac_handle; -} FaacAudioContext; - -static int Faac_encode_init(AVCodecContext *avctx) -{ - FaacAudioContext *s = avctx->priv_data; - faacEncConfigurationPtr faac_cfg; - unsigned long samples_input, max_bytes_output; - - /* number of channels */ - if (avctx->channels < 1 || avctx->channels > 6) - return -1; - - s->faac_handle = faacEncOpen(avctx->sample_rate, - avctx->channels, - &samples_input, &max_bytes_output); - - /* check faac version */ - faac_cfg = faacEncGetCurrentConfiguration(s->faac_handle); - if (faac_cfg->version != FAAC_CFG_VERSION) { - av_log(avctx, AV_LOG_ERROR, "wrong libfaac version (compiled for: %d, using %d)\n", FAAC_CFG_VERSION, faac_cfg->version); - faacEncClose(s->faac_handle); - return -1; - } - - /* put the options in the configuration struct */ - faac_cfg->aacObjectType = LOW; - faac_cfg->mpegVersion = MPEG4; - faac_cfg->useTns = 0; - faac_cfg->allowMidside = 1; - faac_cfg->bitRate = avctx->bit_rate / avctx->channels; - faac_cfg->bandWidth = avctx->cutoff; - if(avctx->flags & CODEC_FLAG_QSCALE) { - faac_cfg->bitRate = 0; - faac_cfg->quantqual = avctx->global_quality / FF_QP2LAMBDA; - } - faac_cfg->outputFormat = 1; - faac_cfg->inputFormat = FAAC_INPUT_16BIT; - - avctx->frame_size = samples_input / avctx->channels; - - avctx->coded_frame= avcodec_alloc_frame(); - avctx->coded_frame->key_frame= 1; - - /* Set decoder specific info */ - avctx->extradata_size = 0; - if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { - - unsigned char *buffer; - unsigned long decoder_specific_info_size; - - if (!faacEncGetDecoderSpecificInfo(s->faac_handle, &buffer, - &decoder_specific_info_size)) { - avctx->extradata = buffer; - avctx->extradata_size = decoder_specific_info_size; - faac_cfg->outputFormat = 0; - } - } - - if (!faacEncSetConfiguration(s->faac_handle, faac_cfg)) { - av_log(avctx, AV_LOG_ERROR, "libfaac doesn't support this output format!\n"); - return -1; - } - - return 0; -} - -int Faac_encode_frame(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) -{ - FaacAudioContext *s = avctx->priv_data; - int bytes_written; - - bytes_written = faacEncEncode(s->faac_handle, - data, - avctx->frame_size * avctx->channels, - frame, - buf_size); - - return bytes_written; -} - -int Faac_encode_close(AVCodecContext *avctx) -{ - FaacAudioContext *s = avctx->priv_data; - - av_freep(&avctx->coded_frame); - - //if (avctx->extradata_size) free(avctx->extradata); - - faacEncClose(s->faac_handle); - return 0; -} - -AVCodec faac_encoder = { - "aac", - CODEC_TYPE_AUDIO, - CODEC_ID_AAC, - sizeof(FaacAudioContext), - Faac_encode_init, - Faac_encode_frame, - Faac_encode_close -};
--- a/src/ffmpeg/libavcodec/flacenc.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1383 +0,0 @@ -/** - * FLAC audio encoder - * Copyright (c) 2006 Justin Ruggles <jruggle@earthlink.net> - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "avcodec.h" -#include "bitstream.h" -#include "crc.h" -#include "golomb.h" -#include "lls.h" - -#define FLAC_MAX_CH 8 -#define FLAC_MIN_BLOCKSIZE 16 -#define FLAC_MAX_BLOCKSIZE 65535 - -#define FLAC_SUBFRAME_CONSTANT 0 -#define FLAC_SUBFRAME_VERBATIM 1 -#define FLAC_SUBFRAME_FIXED 8 -#define FLAC_SUBFRAME_LPC 32 - -#define FLAC_CHMODE_NOT_STEREO 0 -#define FLAC_CHMODE_LEFT_RIGHT 1 -#define FLAC_CHMODE_LEFT_SIDE 8 -#define FLAC_CHMODE_RIGHT_SIDE 9 -#define FLAC_CHMODE_MID_SIDE 10 - -#define ORDER_METHOD_EST 0 -#define ORDER_METHOD_2LEVEL 1 -#define ORDER_METHOD_4LEVEL 2 -#define ORDER_METHOD_8LEVEL 3 -#define ORDER_METHOD_SEARCH 4 -#define ORDER_METHOD_LOG 5 - -#define FLAC_STREAMINFO_SIZE 34 - -#define MIN_LPC_ORDER 1 -#define MAX_LPC_ORDER 32 -#define MAX_FIXED_ORDER 4 -#define MAX_PARTITION_ORDER 8 -#define MAX_PARTITIONS (1 << MAX_PARTITION_ORDER) -#define MAX_LPC_PRECISION 15 -#define MAX_LPC_SHIFT 15 -#define MAX_RICE_PARAM 14 - -typedef struct CompressionOptions { - int compression_level; - int block_time_ms; - int use_lpc; - int lpc_coeff_precision; - int min_prediction_order; - int max_prediction_order; - int prediction_order_method; - int min_partition_order; - int max_partition_order; -} CompressionOptions; - -typedef struct RiceContext { - int porder; - int params[MAX_PARTITIONS]; -} RiceContext; - -typedef struct FlacSubframe { - int type; - int type_code; - int obits; - int order; - int32_t coefs[MAX_LPC_ORDER]; - int shift; - RiceContext rc; - int32_t samples[FLAC_MAX_BLOCKSIZE]; - int32_t residual[FLAC_MAX_BLOCKSIZE]; -} FlacSubframe; - -typedef struct FlacFrame { - FlacSubframe subframes[FLAC_MAX_CH]; - int blocksize; - int bs_code[2]; - uint8_t crc8; - int ch_mode; -} FlacFrame; - -typedef struct FlacEncodeContext { - PutBitContext pb; - int channels; - int ch_code; - int samplerate; - int sr_code[2]; - int blocksize; - int max_framesize; - uint32_t frame_count; - FlacFrame frame; - CompressionOptions options; - AVCodecContext *avctx; -} FlacEncodeContext; - -static const int flac_samplerates[16] = { - 0, 0, 0, 0, - 8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000, - 0, 0, 0, 0 -}; - -static const int flac_blocksizes[16] = { - 0, - 192, - 576, 1152, 2304, 4608, - 0, 0, - 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 -}; - -/** - * Writes streaminfo metadata block to byte array - */ -static void write_streaminfo(FlacEncodeContext *s, uint8_t *header) -{ - PutBitContext pb; - - memset(header, 0, FLAC_STREAMINFO_SIZE); - init_put_bits(&pb, header, FLAC_STREAMINFO_SIZE); - - /* streaminfo metadata block */ - put_bits(&pb, 16, s->blocksize); - put_bits(&pb, 16, s->blocksize); - put_bits(&pb, 24, 0); - put_bits(&pb, 24, s->max_framesize); - put_bits(&pb, 20, s->samplerate); - put_bits(&pb, 3, s->channels-1); - put_bits(&pb, 5, 15); /* bits per sample - 1 */ - flush_put_bits(&pb); - /* total samples = 0 */ - /* MD5 signature = 0 */ -} - -/** - * Sets blocksize based on samplerate - * Chooses the closest predefined blocksize >= BLOCK_TIME_MS milliseconds - */ -static int select_blocksize(int samplerate, int block_time_ms) -{ - int i; - int target; - int blocksize; - - assert(samplerate > 0); - blocksize = flac_blocksizes[1]; - target = (samplerate * block_time_ms) / 1000; - for(i=0; i<16; i++) { - if(target >= flac_blocksizes[i] && flac_blocksizes[i] > blocksize) { - blocksize = flac_blocksizes[i]; - } - } - return blocksize; -} - -static int flac_encode_init(AVCodecContext *avctx) -{ - int freq = avctx->sample_rate; - int channels = avctx->channels; - FlacEncodeContext *s = avctx->priv_data; - int i, level; - uint8_t *streaminfo; - - s->avctx = avctx; - - if(avctx->sample_fmt != SAMPLE_FMT_S16) { - return -1; - } - - if(channels < 1 || channels > FLAC_MAX_CH) { - return -1; - } - s->channels = channels; - s->ch_code = s->channels-1; - - /* find samplerate in table */ - if(freq < 1) - return -1; - for(i=4; i<12; i++) { - if(freq == flac_samplerates[i]) { - s->samplerate = flac_samplerates[i]; - s->sr_code[0] = i; - s->sr_code[1] = 0; - break; - } - } - /* if not in table, samplerate is non-standard */ - if(i == 12) { - if(freq % 1000 == 0 && freq < 255000) { - s->sr_code[0] = 12; - s->sr_code[1] = freq / 1000; - } else if(freq % 10 == 0 && freq < 655350) { - s->sr_code[0] = 14; - s->sr_code[1] = freq / 10; - } else if(freq < 65535) { - s->sr_code[0] = 13; - s->sr_code[1] = freq; - } else { - return -1; - } - s->samplerate = freq; - } - - /* set compression option defaults based on avctx->compression_level */ - if(avctx->compression_level < 0) { - s->options.compression_level = 5; - } else { - s->options.compression_level = avctx->compression_level; - } - av_log(avctx, AV_LOG_DEBUG, " compression: %d\n", s->options.compression_level); - - level= s->options.compression_level; - if(level > 12) { - av_log(avctx, AV_LOG_ERROR, "invalid compression level: %d\n", - s->options.compression_level); - return -1; - } - - s->options.block_time_ms = ((int[]){ 27, 27, 27,105,105,105,105,105,105,105,105,105,105})[level]; - s->options.use_lpc = ((int[]){ 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level]; - s->options.min_prediction_order= ((int[]){ 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1})[level]; - s->options.max_prediction_order= ((int[]){ 3, 4, 4, 6, 8, 8, 8, 8, 12, 12, 12, 32, 32})[level]; - s->options.prediction_order_method = ((int[]){ ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST, - ORDER_METHOD_EST, ORDER_METHOD_EST, ORDER_METHOD_EST, - ORDER_METHOD_4LEVEL, ORDER_METHOD_LOG, ORDER_METHOD_4LEVEL, - ORDER_METHOD_LOG, ORDER_METHOD_SEARCH, ORDER_METHOD_LOG, - ORDER_METHOD_SEARCH})[level]; - s->options.min_partition_order = ((int[]){ 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0})[level]; - s->options.max_partition_order = ((int[]){ 2, 2, 3, 3, 3, 8, 8, 8, 8, 8, 8, 8, 8})[level]; - - /* set compression option overrides from AVCodecContext */ - if(avctx->use_lpc >= 0) { - s->options.use_lpc = clip(avctx->use_lpc, 0, 11); - } - if(s->options.use_lpc == 1) - av_log(avctx, AV_LOG_DEBUG, " use lpc: Levinson-Durbin recursion with Welch window\n"); - else if(s->options.use_lpc > 1) - av_log(avctx, AV_LOG_DEBUG, " use lpc: Cholesky factorization\n"); - - if(avctx->min_prediction_order >= 0) { - if(s->options.use_lpc) { - if(avctx->min_prediction_order < MIN_LPC_ORDER || - avctx->min_prediction_order > MAX_LPC_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", - avctx->min_prediction_order); - return -1; - } - } else { - if(avctx->min_prediction_order > MAX_FIXED_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid min prediction order: %d\n", - avctx->min_prediction_order); - return -1; - } - } - s->options.min_prediction_order = avctx->min_prediction_order; - } - if(avctx->max_prediction_order >= 0) { - if(s->options.use_lpc) { - if(avctx->max_prediction_order < MIN_LPC_ORDER || - avctx->max_prediction_order > MAX_LPC_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", - avctx->max_prediction_order); - return -1; - } - } else { - if(avctx->max_prediction_order > MAX_FIXED_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid max prediction order: %d\n", - avctx->max_prediction_order); - return -1; - } - } - s->options.max_prediction_order = avctx->max_prediction_order; - } - if(s->options.max_prediction_order < s->options.min_prediction_order) { - av_log(avctx, AV_LOG_ERROR, "invalid prediction orders: min=%d max=%d\n", - s->options.min_prediction_order, s->options.max_prediction_order); - return -1; - } - av_log(avctx, AV_LOG_DEBUG, " prediction order: %d, %d\n", - s->options.min_prediction_order, s->options.max_prediction_order); - - if(avctx->prediction_order_method >= 0) { - if(avctx->prediction_order_method > ORDER_METHOD_LOG) { - av_log(avctx, AV_LOG_ERROR, "invalid prediction order method: %d\n", - avctx->prediction_order_method); - return -1; - } - s->options.prediction_order_method = avctx->prediction_order_method; - } - switch(s->options.prediction_order_method) { - case ORDER_METHOD_EST: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", - "estimate"); break; - case ORDER_METHOD_2LEVEL: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", - "2-level"); break; - case ORDER_METHOD_4LEVEL: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", - "4-level"); break; - case ORDER_METHOD_8LEVEL: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", - "8-level"); break; - case ORDER_METHOD_SEARCH: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", - "full search"); break; - case ORDER_METHOD_LOG: av_log(avctx, AV_LOG_DEBUG, " order method: %s\n", - "log search"); break; - } - - if(avctx->min_partition_order >= 0) { - if(avctx->min_partition_order > MAX_PARTITION_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid min partition order: %d\n", - avctx->min_partition_order); - return -1; - } - s->options.min_partition_order = avctx->min_partition_order; - } - if(avctx->max_partition_order >= 0) { - if(avctx->max_partition_order > MAX_PARTITION_ORDER) { - av_log(avctx, AV_LOG_ERROR, "invalid max partition order: %d\n", - avctx->max_partition_order); - return -1; - } - s->options.max_partition_order = avctx->max_partition_order; - } - if(s->options.max_partition_order < s->options.min_partition_order) { - av_log(avctx, AV_LOG_ERROR, "invalid partition orders: min=%d max=%d\n", - s->options.min_partition_order, s->options.max_partition_order); - return -1; - } - av_log(avctx, AV_LOG_DEBUG, " partition order: %d, %d\n", - s->options.min_partition_order, s->options.max_partition_order); - - if(avctx->frame_size > 0) { - if(avctx->frame_size < FLAC_MIN_BLOCKSIZE || - avctx->frame_size > FLAC_MAX_BLOCKSIZE) { - av_log(avctx, AV_LOG_ERROR, "invalid block size: %d\n", - avctx->frame_size); - return -1; - } - s->blocksize = avctx->frame_size; - } else { - s->blocksize = select_blocksize(s->samplerate, s->options.block_time_ms); - avctx->frame_size = s->blocksize; - } - av_log(avctx, AV_LOG_DEBUG, " block size: %d\n", s->blocksize); - - /* set LPC precision */ - if(avctx->lpc_coeff_precision > 0) { - if(avctx->lpc_coeff_precision > MAX_LPC_PRECISION) { - av_log(avctx, AV_LOG_ERROR, "invalid lpc coeff precision: %d\n", - avctx->lpc_coeff_precision); - return -1; - } - s->options.lpc_coeff_precision = avctx->lpc_coeff_precision; - } else { - /* select LPC precision based on block size */ - if( s->blocksize <= 192) s->options.lpc_coeff_precision = 7; - else if(s->blocksize <= 384) s->options.lpc_coeff_precision = 8; - else if(s->blocksize <= 576) s->options.lpc_coeff_precision = 9; - else if(s->blocksize <= 1152) s->options.lpc_coeff_precision = 10; - else if(s->blocksize <= 2304) s->options.lpc_coeff_precision = 11; - else if(s->blocksize <= 4608) s->options.lpc_coeff_precision = 12; - else if(s->blocksize <= 8192) s->options.lpc_coeff_precision = 13; - else if(s->blocksize <= 16384) s->options.lpc_coeff_precision = 14; - else s->options.lpc_coeff_precision = 15; - } - av_log(avctx, AV_LOG_DEBUG, " lpc precision: %d\n", - s->options.lpc_coeff_precision); - - /* set maximum encoded frame size in verbatim mode */ - if(s->channels == 2) { - s->max_framesize = 14 + ((s->blocksize * 33 + 7) >> 3); - } else { - s->max_framesize = 14 + (s->blocksize * s->channels * 2); - } - - streaminfo = av_malloc(FLAC_STREAMINFO_SIZE); - write_streaminfo(s, streaminfo); - avctx->extradata = streaminfo; - avctx->extradata_size = FLAC_STREAMINFO_SIZE; - - s->frame_count = 0; - - avctx->coded_frame = avcodec_alloc_frame(); - avctx->coded_frame->key_frame = 1; - - return 0; -} - -static void init_frame(FlacEncodeContext *s) -{ - int i, ch; - FlacFrame *frame; - - frame = &s->frame; - - for(i=0; i<16; i++) { - if(s->blocksize == flac_blocksizes[i]) { - frame->blocksize = flac_blocksizes[i]; - frame->bs_code[0] = i; - frame->bs_code[1] = 0; - break; - } - } - if(i == 16) { - frame->blocksize = s->blocksize; - if(frame->blocksize <= 256) { - frame->bs_code[0] = 6; - frame->bs_code[1] = frame->blocksize-1; - } else { - frame->bs_code[0] = 7; - frame->bs_code[1] = frame->blocksize-1; - } - } - - for(ch=0; ch<s->channels; ch++) { - frame->subframes[ch].obits = 16; - } -} - -/** - * Copy channel-interleaved input samples into separate subframes - */ -static void copy_samples(FlacEncodeContext *s, int16_t *samples) -{ - int i, j, ch; - FlacFrame *frame; - - frame = &s->frame; - for(i=0,j=0; i<frame->blocksize; i++) { - for(ch=0; ch<s->channels; ch++,j++) { - frame->subframes[ch].samples[i] = samples[j]; - } - } -} - - -#define rice_encode_count(sum, n, k) (((n)*((k)+1))+((sum-(n>>1))>>(k))) - -static int find_optimal_param(uint32_t sum, int n) -{ - int k, k_opt; - uint32_t nbits[MAX_RICE_PARAM+1]; - - k_opt = 0; - nbits[0] = UINT32_MAX; - for(k=0; k<=MAX_RICE_PARAM; k++) { - nbits[k] = rice_encode_count(sum, n, k); - if(nbits[k] < nbits[k_opt]) { - k_opt = k; - } - } - return k_opt; -} - -static uint32_t calc_optimal_rice_params(RiceContext *rc, int porder, - uint32_t *sums, int n, int pred_order) -{ - int i; - int k, cnt, part; - uint32_t all_bits; - - part = (1 << porder); - all_bits = 0; - - cnt = (n >> porder) - pred_order; - for(i=0; i<part; i++) { - if(i == 1) cnt = (n >> porder); - k = find_optimal_param(sums[i], cnt); - rc->params[i] = k; - all_bits += rice_encode_count(sums[i], cnt, k); - } - all_bits += (4 * part); - - rc->porder = porder; - - return all_bits; -} - -static void calc_sums(int pmin, int pmax, uint32_t *data, int n, int pred_order, - uint32_t sums[][MAX_PARTITIONS]) -{ - int i, j; - int parts; - uint32_t *res, *res_end; - - /* sums for highest level */ - parts = (1 << pmax); - res = &data[pred_order]; - res_end = &data[n >> pmax]; - for(i=0; i<parts; i++) { - sums[pmax][i] = 0; - while(res < res_end){ - sums[pmax][i] += *(res++); - } - res_end+= n >> pmax; - } - /* sums for lower levels */ - for(i=pmax-1; i>=pmin; i--) { - parts = (1 << i); - for(j=0; j<parts; j++) { - sums[i][j] = sums[i+1][2*j] + sums[i+1][2*j+1]; - } - } -} - -static uint32_t calc_rice_params(RiceContext *rc, int pmin, int pmax, - int32_t *data, int n, int pred_order) -{ - int i; - uint32_t bits[MAX_PARTITION_ORDER+1]; - int opt_porder; - RiceContext tmp_rc; - uint32_t *udata; - uint32_t sums[MAX_PARTITION_ORDER+1][MAX_PARTITIONS]; - - assert(pmin >= 0 && pmin <= MAX_PARTITION_ORDER); - assert(pmax >= 0 && pmax <= MAX_PARTITION_ORDER); - assert(pmin <= pmax); - - udata = av_malloc(n * sizeof(uint32_t)); - for(i=0; i<n; i++) { - udata[i] = (2*data[i]) ^ (data[i]>>31); - } - - calc_sums(pmin, pmax, udata, n, pred_order, sums); - - opt_porder = pmin; - bits[pmin] = UINT32_MAX; - for(i=pmin; i<=pmax; i++) { - bits[i] = calc_optimal_rice_params(&tmp_rc, i, sums[i], n, pred_order); - if(bits[i] <= bits[opt_porder]) { - opt_porder = i; - *rc= tmp_rc; - } - } - - av_freep(&udata); - return bits[opt_porder]; -} - -static int get_max_p_order(int max_porder, int n, int order) -{ - int porder = FFMIN(max_porder, av_log2(n^(n-1))); - if(order > 0) - porder = FFMIN(porder, av_log2(n/order)); - return porder; -} - -static uint32_t calc_rice_params_fixed(RiceContext *rc, int pmin, int pmax, - int32_t *data, int n, int pred_order, - int bps) -{ - uint32_t bits; - pmin = get_max_p_order(pmin, n, pred_order); - pmax = get_max_p_order(pmax, n, pred_order); - bits = pred_order*bps + 6; - bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order); - return bits; -} - -static uint32_t calc_rice_params_lpc(RiceContext *rc, int pmin, int pmax, - int32_t *data, int n, int pred_order, - int bps, int precision) -{ - uint32_t bits; - pmin = get_max_p_order(pmin, n, pred_order); - pmax = get_max_p_order(pmax, n, pred_order); - bits = pred_order*bps + 4 + 5 + pred_order*precision + 6; - bits += calc_rice_params(rc, pmin, pmax, data, n, pred_order); - return bits; -} - -/** - * Apply Welch window function to audio block - */ -static void apply_welch_window(const int32_t *data, int len, double *w_data) -{ - int i, n2; - double w; - double c; - - n2 = (len >> 1); - c = 2.0 / (len - 1.0); - for(i=0; i<n2; i++) { - w = c - i - 1.0; - w = 1.0 - (w * w); - w_data[i] = data[i] * w; - w_data[len-1-i] = data[len-1-i] * w; - } -} - -/** - * Calculates autocorrelation data from audio samples - * A Welch window function is applied before calculation. - */ -static void compute_autocorr(const int32_t *data, int len, int lag, - double *autoc) -{ - int i, lag_ptr; - double tmp[len + lag]; - double *data1= tmp + lag; - - apply_welch_window(data, len, data1); - - for(i=0; i<lag; i++){ - autoc[i] = 1.0; - data1[i-lag]= 0.0; - } - - for(i=0; i<len; i++){ - for(lag_ptr= i-lag; lag_ptr<=i; lag_ptr++){ - autoc[i-lag_ptr] += data1[i] * data1[lag_ptr]; - } - } -} - -/** - * Levinson-Durbin recursion. - * Produces LPC coefficients from autocorrelation data. - */ -static void compute_lpc_coefs(const double *autoc, int max_order, - double lpc[][MAX_LPC_ORDER], double *ref) -{ - int i, j, i2; - double r, err, tmp; - double lpc_tmp[MAX_LPC_ORDER]; - - for(i=0; i<max_order; i++) lpc_tmp[i] = 0; - err = autoc[0]; - - for(i=0; i<max_order; i++) { - r = -autoc[i+1]; - for(j=0; j<i; j++) { - r -= lpc_tmp[j] * autoc[i-j]; - } - r /= err; - ref[i] = fabs(r); - - err *= 1.0 - (r * r); - - i2 = (i >> 1); - lpc_tmp[i] = r; - for(j=0; j<i2; j++) { - tmp = lpc_tmp[j]; - lpc_tmp[j] += r * lpc_tmp[i-1-j]; - lpc_tmp[i-1-j] += r * tmp; - } - if(i & 1) { - lpc_tmp[j] += lpc_tmp[j] * r; - } - - for(j=0; j<=i; j++) { - lpc[i][j] = -lpc_tmp[j]; - } - } -} - -/** - * Quantize LPC coefficients - */ -static void quantize_lpc_coefs(double *lpc_in, int order, int precision, - int32_t *lpc_out, int *shift) -{ - int i; - double cmax, error; - int32_t qmax; - int sh; - - /* define maximum levels */ - qmax = (1 << (precision - 1)) - 1; - - /* find maximum coefficient value */ - cmax = 0.0; - for(i=0; i<order; i++) { - cmax= FFMAX(cmax, fabs(lpc_in[i])); - } - - /* if maximum value quantizes to zero, return all zeros */ - if(cmax * (1 << MAX_LPC_SHIFT) < 1.0) { - *shift = 0; - memset(lpc_out, 0, sizeof(int32_t) * order); - return; - } - - /* calculate level shift which scales max coeff to available bits */ - sh = MAX_LPC_SHIFT; - while((cmax * (1 << sh) > qmax) && (sh > 0)) { - sh--; - } - - /* since negative shift values are unsupported in decoder, scale down - coefficients instead */ - if(sh == 0 && cmax > qmax) { - double scale = ((double)qmax) / cmax; - for(i=0; i<order; i++) { - lpc_in[i] *= scale; - } - } - - /* output quantized coefficients and level shift */ - error=0; - for(i=0; i<order; i++) { - error += lpc_in[i] * (1 << sh); - lpc_out[i] = clip(lrintf(error), -qmax, qmax); - error -= lpc_out[i]; - } - *shift = sh; -} - -static int estimate_best_order(double *ref, int max_order) -{ - int i, est; - - est = 1; - for(i=max_order-1; i>=0; i--) { - if(ref[i] > 0.10) { - est = i+1; - break; - } - } - return est; -} - -/** - * Calculate LPC coefficients for multiple orders - */ -static int lpc_calc_coefs(const int32_t *samples, int blocksize, int max_order, - int precision, int32_t coefs[][MAX_LPC_ORDER], - int *shift, int use_lpc, int omethod) -{ - double autoc[MAX_LPC_ORDER+1]; - double ref[MAX_LPC_ORDER]; - double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER]; - int i, j, pass; - int opt_order; - - assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER); - - if(use_lpc == 1){ - compute_autocorr(samples, blocksize, max_order+1, autoc); - - compute_lpc_coefs(autoc, max_order, lpc, ref); - }else{ - LLSModel m[2]; - double var[MAX_LPC_ORDER+1], eval, weight; - - for(pass=0; pass<use_lpc-1; pass++){ - av_init_lls(&m[pass&1], max_order); - - weight=0; - for(i=max_order; i<blocksize; i++){ - for(j=0; j<=max_order; j++) - var[j]= samples[i-j]; - - if(pass){ - eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1); - eval= (512>>pass) + fabs(eval - var[0]); - for(j=0; j<=max_order; j++) - var[j]/= sqrt(eval); - weight += 1/eval; - }else - weight++; - - av_update_lls(&m[pass&1], var, 1.0); - } - av_solve_lls(&m[pass&1], 0.001, 0); - } - - for(i=0; i<max_order; i++){ - for(j=0; j<max_order; j++) - lpc[i][j]= m[(pass-1)&1].coeff[i][j]; - ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000; - } - for(i=max_order-1; i>0; i--) - ref[i] = ref[i-1] - ref[i]; - } - opt_order = max_order; - - if(omethod == ORDER_METHOD_EST) { - opt_order = estimate_best_order(ref, max_order); - i = opt_order-1; - quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i]); - } else { - for(i=0; i<max_order; i++) { - quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i]); - } - } - - return opt_order; -} - - -static void encode_residual_verbatim(int32_t *res, int32_t *smp, int n) -{ - assert(n > 0); - memcpy(res, smp, n * sizeof(int32_t)); -} - -static void encode_residual_fixed(int32_t *res, const int32_t *smp, int n, - int order) -{ - int i; - - for(i=0; i<order; i++) { - res[i] = smp[i]; - } - - if(order==0){ - for(i=order; i<n; i++) - res[i]= smp[i]; - }else if(order==1){ - for(i=order; i<n; i++) - res[i]= smp[i] - smp[i-1]; - }else if(order==2){ - for(i=order; i<n; i++) - res[i]= smp[i] - 2*smp[i-1] + smp[i-2]; - }else if(order==3){ - for(i=order; i<n; i++) - res[i]= smp[i] - 3*smp[i-1] + 3*smp[i-2] - smp[i-3]; - }else{ - for(i=order; i<n; i++) - res[i]= smp[i] - 4*smp[i-1] + 6*smp[i-2] - 4*smp[i-3] + smp[i-4]; - } -} - -static void encode_residual_lpc(int32_t *res, const int32_t *smp, int n, - int order, const int32_t *coefs, int shift) -{ - int i, j; - int32_t pred; - - for(i=0; i<order; i++) { - res[i] = smp[i]; - } - for(i=order; i<n; i++) { - pred = 0; - for(j=0; j<order; j++) { - pred += coefs[j] * smp[i-j-1]; - } - res[i] = smp[i] - (pred >> shift); - } -} - -static int encode_residual(FlacEncodeContext *ctx, int ch) -{ - int i, n; - int min_order, max_order, opt_order, precision, omethod; - int min_porder, max_porder; - FlacFrame *frame; - FlacSubframe *sub; - int32_t coefs[MAX_LPC_ORDER][MAX_LPC_ORDER]; - int shift[MAX_LPC_ORDER]; - int32_t *res, *smp; - - frame = &ctx->frame; - sub = &frame->subframes[ch]; - res = sub->residual; - smp = sub->samples; - n = frame->blocksize; - - /* CONSTANT */ - for(i=1; i<n; i++) { - if(smp[i] != smp[0]) break; - } - if(i == n) { - sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT; - res[0] = smp[0]; - return sub->obits; - } - - /* VERBATIM */ - if(n < 5) { - sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM; - encode_residual_verbatim(res, smp, n); - return sub->obits * n; - } - - min_order = ctx->options.min_prediction_order; - max_order = ctx->options.max_prediction_order; - min_porder = ctx->options.min_partition_order; - max_porder = ctx->options.max_partition_order; - precision = ctx->options.lpc_coeff_precision; - omethod = ctx->options.prediction_order_method; - - /* FIXED */ - if(!ctx->options.use_lpc || max_order == 0 || (n <= max_order)) { - uint32_t bits[MAX_FIXED_ORDER+1]; - if(max_order > MAX_FIXED_ORDER) max_order = MAX_FIXED_ORDER; - opt_order = 0; - bits[0] = UINT32_MAX; - for(i=min_order; i<=max_order; i++) { - encode_residual_fixed(res, smp, n, i); - bits[i] = calc_rice_params_fixed(&sub->rc, min_porder, max_porder, res, - n, i, sub->obits); - if(bits[i] < bits[opt_order]) { - opt_order = i; - } - } - sub->order = opt_order; - sub->type = FLAC_SUBFRAME_FIXED; - sub->type_code = sub->type | sub->order; - if(sub->order != max_order) { - encode_residual_fixed(res, smp, n, sub->order); - return calc_rice_params_fixed(&sub->rc, min_porder, max_porder, res, n, - sub->order, sub->obits); - } - return bits[sub->order]; - } - - /* LPC */ - opt_order = lpc_calc_coefs(smp, n, max_order, precision, coefs, shift, ctx->options.use_lpc, omethod); - - if(omethod == ORDER_METHOD_2LEVEL || - omethod == ORDER_METHOD_4LEVEL || - omethod == ORDER_METHOD_8LEVEL) { - int levels = 1 << omethod; - uint32_t bits[levels]; - int order; - int opt_index = levels-1; - opt_order = max_order-1; - bits[opt_index] = UINT32_MAX; - for(i=levels-1; i>=0; i--) { - order = min_order + (((max_order-min_order+1) * (i+1)) / levels)-1; - if(order < 0) order = 0; - encode_residual_lpc(res, smp, n, order+1, coefs[order], shift[order]); - bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder, - res, n, order+1, sub->obits, precision); - if(bits[i] < bits[opt_index]) { - opt_index = i; - opt_order = order; - } - } - opt_order++; - } else if(omethod == ORDER_METHOD_SEARCH) { - // brute-force optimal order search - uint32_t bits[MAX_LPC_ORDER]; - opt_order = 0; - bits[0] = UINT32_MAX; - for(i=min_order-1; i<max_order; i++) { - encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]); - bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder, - res, n, i+1, sub->obits, precision); - if(bits[i] < bits[opt_order]) { - opt_order = i; - } - } - opt_order++; - } else if(omethod == ORDER_METHOD_LOG) { - uint32_t bits[MAX_LPC_ORDER]; - int step; - - opt_order= min_order - 1 + (max_order-min_order)/3; - memset(bits, -1, sizeof(bits)); - - for(step=16 ;step; step>>=1){ - int last= opt_order; - for(i=last-step; i<=last+step; i+= step){ - if(i<min_order-1 || i>=max_order || bits[i] < UINT32_MAX) - continue; - encode_residual_lpc(res, smp, n, i+1, coefs[i], shift[i]); - bits[i] = calc_rice_params_lpc(&sub->rc, min_porder, max_porder, - res, n, i+1, sub->obits, precision); - if(bits[i] < bits[opt_order]) - opt_order= i; - } - } - opt_order++; - } - - sub->order = opt_order; - sub->type = FLAC_SUBFRAME_LPC; - sub->type_code = sub->type | (sub->order-1); - sub->shift = shift[sub->order-1]; - for(i=0; i<sub->order; i++) { - sub->coefs[i] = coefs[sub->order-1][i]; - } - encode_residual_lpc(res, smp, n, sub->order, sub->coefs, sub->shift); - return calc_rice_params_lpc(&sub->rc, min_porder, max_porder, res, n, sub->order, - sub->obits, precision); -} - -static int encode_residual_v(FlacEncodeContext *ctx, int ch) -{ - int i, n; - FlacFrame *frame; - FlacSubframe *sub; - int32_t *res, *smp; - - frame = &ctx->frame; - sub = &frame->subframes[ch]; - res = sub->residual; - smp = sub->samples; - n = frame->blocksize; - - /* CONSTANT */ - for(i=1; i<n; i++) { - if(smp[i] != smp[0]) break; - } - if(i == n) { - sub->type = sub->type_code = FLAC_SUBFRAME_CONSTANT; - res[0] = smp[0]; - return sub->obits; - } - - /* VERBATIM */ - sub->type = sub->type_code = FLAC_SUBFRAME_VERBATIM; - encode_residual_verbatim(res, smp, n); - return sub->obits * n; -} - -static int estimate_stereo_mode(int32_t *left_ch, int32_t *right_ch, int n) -{ - int i, best; - int32_t lt, rt; - uint64_t sum[4]; - uint64_t score[4]; - int k; - - /* calculate sum of 2nd order residual for each channel */ - sum[0] = sum[1] = sum[2] = sum[3] = 0; - for(i=2; i<n; i++) { - lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2]; - rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2]; - sum[2] += FFABS((lt + rt) >> 1); - sum[3] += FFABS(lt - rt); - sum[0] += FFABS(lt); - sum[1] += FFABS(rt); - } - /* estimate bit counts */ - for(i=0; i<4; i++) { - k = find_optimal_param(2*sum[i], n); - sum[i] = rice_encode_count(2*sum[i], n, k); - } - - /* calculate score for each mode */ - score[0] = sum[0] + sum[1]; - score[1] = sum[0] + sum[3]; - score[2] = sum[1] + sum[3]; - score[3] = sum[2] + sum[3]; - - /* return mode with lowest score */ - best = 0; - for(i=1; i<4; i++) { - if(score[i] < score[best]) { - best = i; - } - } - if(best == 0) { - return FLAC_CHMODE_LEFT_RIGHT; - } else if(best == 1) { - return FLAC_CHMODE_LEFT_SIDE; - } else if(best == 2) { - return FLAC_CHMODE_RIGHT_SIDE; - } else { - return FLAC_CHMODE_MID_SIDE; - } -} - -/** - * Perform stereo channel decorrelation - */ -static void channel_decorrelation(FlacEncodeContext *ctx) -{ - FlacFrame *frame; - int32_t *left, *right; - int i, n; - - frame = &ctx->frame; - n = frame->blocksize; - left = frame->subframes[0].samples; - right = frame->subframes[1].samples; - - if(ctx->channels != 2) { - frame->ch_mode = FLAC_CHMODE_NOT_STEREO; - return; - } - - frame->ch_mode = estimate_stereo_mode(left, right, n); - - /* perform decorrelation and adjust bits-per-sample */ - if(frame->ch_mode == FLAC_CHMODE_LEFT_RIGHT) { - return; - } - if(frame->ch_mode == FLAC_CHMODE_MID_SIDE) { - int32_t tmp; - for(i=0; i<n; i++) { - tmp = left[i]; - left[i] = (tmp + right[i]) >> 1; - right[i] = tmp - right[i]; - } - frame->subframes[1].obits++; - } else if(frame->ch_mode == FLAC_CHMODE_LEFT_SIDE) { - for(i=0; i<n; i++) { - right[i] = left[i] - right[i]; - } - frame->subframes[1].obits++; - } else { - for(i=0; i<n; i++) { - left[i] -= right[i]; - } - frame->subframes[0].obits++; - } -} - -static void put_sbits(PutBitContext *pb, int bits, int32_t val) -{ - assert(bits >= 0 && bits <= 31); - - put_bits(pb, bits, val & ((1<<bits)-1)); -} - -static void write_utf8(PutBitContext *pb, uint32_t val) -{ - int bytes, shift; - - if(val < 0x80){ - put_bits(pb, 8, val); - return; - } - - bytes= (av_log2(val)+4) / 5; - shift = (bytes - 1) * 6; - put_bits(pb, 8, (256 - (256>>bytes)) | (val >> shift)); - while(shift >= 6){ - shift -= 6; - put_bits(pb, 8, 0x80 | ((val >> shift) & 0x3F)); - } -} - -static void output_frame_header(FlacEncodeContext *s) -{ - FlacFrame *frame; - int crc; - - frame = &s->frame; - - put_bits(&s->pb, 16, 0xFFF8); - put_bits(&s->pb, 4, frame->bs_code[0]); - put_bits(&s->pb, 4, s->sr_code[0]); - if(frame->ch_mode == FLAC_CHMODE_NOT_STEREO) { - put_bits(&s->pb, 4, s->ch_code); - } else { - put_bits(&s->pb, 4, frame->ch_mode); - } - put_bits(&s->pb, 3, 4); /* bits-per-sample code */ - put_bits(&s->pb, 1, 0); - write_utf8(&s->pb, s->frame_count); - if(frame->bs_code[0] == 6) { - put_bits(&s->pb, 8, frame->bs_code[1]); - } else if(frame->bs_code[0] == 7) { - put_bits(&s->pb, 16, frame->bs_code[1]); - } - if(s->sr_code[0] == 12) { - put_bits(&s->pb, 8, s->sr_code[1]); - } else if(s->sr_code[0] > 12) { - put_bits(&s->pb, 16, s->sr_code[1]); - } - flush_put_bits(&s->pb); - crc = av_crc(av_crc07, 0, s->pb.buf, put_bits_count(&s->pb)>>3); - put_bits(&s->pb, 8, crc); -} - -static void output_subframe_constant(FlacEncodeContext *s, int ch) -{ - FlacSubframe *sub; - int32_t res; - - sub = &s->frame.subframes[ch]; - res = sub->residual[0]; - put_sbits(&s->pb, sub->obits, res); -} - -static void output_subframe_verbatim(FlacEncodeContext *s, int ch) -{ - int i; - FlacFrame *frame; - FlacSubframe *sub; - int32_t res; - - frame = &s->frame; - sub = &frame->subframes[ch]; - - for(i=0; i<frame->blocksize; i++) { - res = sub->residual[i]; - put_sbits(&s->pb, sub->obits, res); - } -} - -static void output_residual(FlacEncodeContext *ctx, int ch) -{ - int i, j, p, n, parts; - int k, porder, psize, res_cnt; - FlacFrame *frame; - FlacSubframe *sub; - int32_t *res; - - frame = &ctx->frame; - sub = &frame->subframes[ch]; - res = sub->residual; - n = frame->blocksize; - - /* rice-encoded block */ - put_bits(&ctx->pb, 2, 0); - - /* partition order */ - porder = sub->rc.porder; - psize = n >> porder; - parts = (1 << porder); - put_bits(&ctx->pb, 4, porder); - res_cnt = psize - sub->order; - - /* residual */ - j = sub->order; - for(p=0; p<parts; p++) { - k = sub->rc.params[p]; - put_bits(&ctx->pb, 4, k); - if(p == 1) res_cnt = psize; - for(i=0; i<res_cnt && j<n; i++, j++) { - set_sr_golomb_flac(&ctx->pb, res[j], k, INT32_MAX, 0); - } - } -} - -static void output_subframe_fixed(FlacEncodeContext *ctx, int ch) -{ - int i; - FlacFrame *frame; - FlacSubframe *sub; - - frame = &ctx->frame; - sub = &frame->subframes[ch]; - - /* warm-up samples */ - for(i=0; i<sub->order; i++) { - put_sbits(&ctx->pb, sub->obits, sub->residual[i]); - } - - /* residual */ - output_residual(ctx, ch); -} - -static void output_subframe_lpc(FlacEncodeContext *ctx, int ch) -{ - int i, cbits; - FlacFrame *frame; - FlacSubframe *sub; - - frame = &ctx->frame; - sub = &frame->subframes[ch]; - - /* warm-up samples */ - for(i=0; i<sub->order; i++) { - put_sbits(&ctx->pb, sub->obits, sub->residual[i]); - } - - /* LPC coefficients */ - cbits = ctx->options.lpc_coeff_precision; - put_bits(&ctx->pb, 4, cbits-1); - put_sbits(&ctx->pb, 5, sub->shift); - for(i=0; i<sub->order; i++) { - put_sbits(&ctx->pb, cbits, sub->coefs[i]); - } - - /* residual */ - output_residual(ctx, ch); -} - -static void output_subframes(FlacEncodeContext *s) -{ - FlacFrame *frame; - FlacSubframe *sub; - int ch; - - frame = &s->frame; - - for(ch=0; ch<s->channels; ch++) { - sub = &frame->subframes[ch]; - - /* subframe header */ - put_bits(&s->pb, 1, 0); - put_bits(&s->pb, 6, sub->type_code); - put_bits(&s->pb, 1, 0); /* no wasted bits */ - - /* subframe */ - if(sub->type == FLAC_SUBFRAME_CONSTANT) { - output_subframe_constant(s, ch); - } else if(sub->type == FLAC_SUBFRAME_VERBATIM) { - output_subframe_verbatim(s, ch); - } else if(sub->type == FLAC_SUBFRAME_FIXED) { - output_subframe_fixed(s, ch); - } else if(sub->type == FLAC_SUBFRAME_LPC) { - output_subframe_lpc(s, ch); - } - } -} - -static void output_frame_footer(FlacEncodeContext *s) -{ - int crc; - flush_put_bits(&s->pb); - crc = bswap_16(av_crc(av_crc8005, 0, s->pb.buf, put_bits_count(&s->pb)>>3)); - put_bits(&s->pb, 16, crc); - flush_put_bits(&s->pb); -} - -static int flac_encode_frame(AVCodecContext *avctx, uint8_t *frame, - int buf_size, void *data) -{ - int ch; - FlacEncodeContext *s; - int16_t *samples = data; - int out_bytes; - - s = avctx->priv_data; - - s->blocksize = avctx->frame_size; - init_frame(s); - - copy_samples(s, samples); - - channel_decorrelation(s); - - for(ch=0; ch<s->channels; ch++) { - encode_residual(s, ch); - } - init_put_bits(&s->pb, frame, buf_size); - output_frame_header(s); - output_subframes(s); - output_frame_footer(s); - out_bytes = put_bits_count(&s->pb) >> 3; - - if(out_bytes > s->max_framesize || out_bytes >= buf_size) { - /* frame too large. use verbatim mode */ - for(ch=0; ch<s->channels; ch++) { - encode_residual_v(s, ch); - } - init_put_bits(&s->pb, frame, buf_size); - output_frame_header(s); - output_subframes(s); - output_frame_footer(s); - out_bytes = put_bits_count(&s->pb) >> 3; - - if(out_bytes > s->max_framesize || out_bytes >= buf_size) { - /* still too large. must be an error. */ - av_log(avctx, AV_LOG_ERROR, "error encoding frame\n"); - return -1; - } - } - - s->frame_count++; - return out_bytes; -} - -static int flac_encode_close(AVCodecContext *avctx) -{ - av_freep(&avctx->extradata); - avctx->extradata_size = 0; - av_freep(&avctx->coded_frame); - return 0; -} - -AVCodec flac_encoder = { - "flac", - CODEC_TYPE_AUDIO, - CODEC_ID_FLAC, - sizeof(FlacEncodeContext), - flac_encode_init, - flac_encode_frame, - flac_encode_close, - NULL, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME, -};
--- a/src/ffmpeg/libavcodec/flicvideo.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,748 +0,0 @@ -/* - * FLI/FLC Animation Video Decoder - * Copyright (C) 2003, 2004 the ffmpeg project - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/** - * @file flic.c - * Autodesk Animator FLI/FLC Video Decoder - * by Mike Melanson (melanson@pcisys.net) - * for more information on the .fli/.flc file format and all of its many - * variations, visit: - * http://www.compuphase.com/flic.htm - * - * This decoder outputs PAL8/RGB555/RGB565 and maybe one day RGB24 - * colorspace data, depending on the FLC. To use this decoder, be - * sure that your demuxer sends the FLI file header to the decoder via - * the extradata chunk in AVCodecContext. The chunk should be 128 bytes - * large. The only exception is for FLI files from the game "Magic Carpet", - * in which the header is only 12 bytes. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "common.h" -#include "avcodec.h" -#include "bswap.h" - -#define FLI_256_COLOR 4 -#define FLI_DELTA 7 -#define FLI_COLOR 11 -#define FLI_LC 12 -#define FLI_BLACK 13 -#define FLI_BRUN 15 -#define FLI_COPY 16 -#define FLI_MINI 18 -#define FLI_DTA_BRUN 25 -#define FLI_DTA_COPY 26 -#define FLI_DTA_LC 27 - -#define FLI_TYPE_CODE (0xAF11) -#define FLC_FLX_TYPE_CODE (0xAF12) -#define FLC_DTA_TYPE_CODE (0xAF44) /* Marks an "Extended FLC" comes from Dave's Targa Animator (DTA) */ -#define FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE (0xAF13) - -#define CHECK_PIXEL_PTR(n) \ - if (pixel_ptr + n > pixel_limit) { \ - av_log (s->avctx, AV_LOG_INFO, "Problem: pixel_ptr >= pixel_limit (%d >= %d)\n", \ - pixel_ptr + n, pixel_limit); \ - return -1; \ - } \ - -typedef struct FlicDecodeContext { - AVCodecContext *avctx; - AVFrame frame; - - unsigned int palette[256]; - int new_palette; - int fli_type; /* either 0xAF11 or 0xAF12, affects palette resolution */ -} FlicDecodeContext; - -static int flic_decode_init(AVCodecContext *avctx) -{ - FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data; - unsigned char *fli_header = (unsigned char *)avctx->extradata; - int depth; - - s->avctx = avctx; - avctx->has_b_frames = 0; - - s->fli_type = LE_16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */ - depth = LE_16(&fli_header[12]); - - if (depth == 0) { - depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */ - } - - if (s->avctx->extradata_size == 12) { - /* special case for magic carpet FLIs */ - s->fli_type = FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE; - } else if (s->avctx->extradata_size != 128) { - av_log(avctx, AV_LOG_ERROR, "Expected extradata of 12 or 128 bytes\n"); - return -1; - } - - if ((s->fli_type == FLC_FLX_TYPE_CODE) && (depth == 16)) { - depth = 15; /* Original Autodesk FLX's say the depth is 16Bpp when it is really 15Bpp */ - } - - switch (depth) { - case 8 : avctx->pix_fmt = PIX_FMT_PAL8; break; - case 15 : avctx->pix_fmt = PIX_FMT_RGB555; break; - case 16 : avctx->pix_fmt = PIX_FMT_RGB565; break; - case 24 : avctx->pix_fmt = PIX_FMT_BGR24; /* Supposedly BGR, but havent any files to test with */ - av_log(avctx, AV_LOG_ERROR, "24Bpp FLC/FLX is unsupported due to no test files.\n"); - return -1; - break; - default : - av_log(avctx, AV_LOG_ERROR, "Unkown FLC/FLX depth of %d Bpp is unsupported.\n",depth); - return -1; - } - - s->frame.data[0] = NULL; - s->new_palette = 0; - - return 0; -} - -static int flic_decode_frame_8BPP(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data; - - int stream_ptr = 0; - int stream_ptr_after_color_chunk; - int pixel_ptr; - int palette_ptr; - unsigned char palette_idx1; - unsigned char palette_idx2; - - unsigned int frame_size; - int num_chunks; - - unsigned int chunk_size; - int chunk_type; - - int i, j; - - int color_packets; - int color_changes; - int color_shift; - unsigned char r, g, b; - - int lines; - int compressed_lines; - int starting_line; - signed short line_packets; - int y_ptr; - signed char byte_run; - int pixel_skip; - int pixel_countdown; - unsigned char *pixels; - int pixel_limit; - - s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &s->frame) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; - } - - pixels = s->frame.data[0]; - pixel_limit = s->avctx->height * s->frame.linesize[0]; - - frame_size = LE_32(&buf[stream_ptr]); - stream_ptr += 6; /* skip the magic number */ - num_chunks = LE_16(&buf[stream_ptr]); - stream_ptr += 10; /* skip padding */ - - frame_size -= 16; - - /* iterate through the chunks */ - while ((frame_size > 0) && (num_chunks > 0)) { - chunk_size = LE_32(&buf[stream_ptr]); - stream_ptr += 4; - chunk_type = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - - switch (chunk_type) { - case FLI_256_COLOR: - case FLI_COLOR: - stream_ptr_after_color_chunk = stream_ptr + chunk_size - 6; - - /* check special case: If this file is from the Magic Carpet - * game and uses 6-bit colors even though it reports 256-color - * chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during - * initialization) */ - if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE)) - color_shift = 0; - else - color_shift = 2; - /* set up the palette */ - color_packets = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - palette_ptr = 0; - for (i = 0; i < color_packets; i++) { - /* first byte is how many colors to skip */ - palette_ptr += buf[stream_ptr++]; - - /* next byte indicates how many entries to change */ - color_changes = buf[stream_ptr++]; - - /* if there are 0 color changes, there are actually 256 */ - if (color_changes == 0) - color_changes = 256; - - for (j = 0; j < color_changes; j++) { - unsigned int entry; - - /* wrap around, for good measure */ - if ((unsigned)palette_ptr >= 256) - palette_ptr = 0; - - r = buf[stream_ptr++] << color_shift; - g = buf[stream_ptr++] << color_shift; - b = buf[stream_ptr++] << color_shift; - entry = (r << 16) | (g << 8) | b; - if (s->palette[palette_ptr] != entry) - s->new_palette = 1; - s->palette[palette_ptr++] = entry; - } - } - - /* color chunks sometimes have weird 16-bit alignment issues; - * therefore, take the hardline approach and set the stream_ptr - * to the value calculated w.r.t. the size specified by the color - * chunk header */ - stream_ptr = stream_ptr_after_color_chunk; - - break; - - case FLI_DELTA: - y_ptr = 0; - compressed_lines = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - while (compressed_lines > 0) { - line_packets = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - if (line_packets < 0) { - line_packets = -line_packets; - y_ptr += line_packets * s->frame.linesize[0]; - } else { - compressed_lines--; - pixel_ptr = y_ptr; - pixel_countdown = s->avctx->width; - for (i = 0; i < line_packets; i++) { - /* account for the skip bytes */ - pixel_skip = buf[stream_ptr++]; - pixel_ptr += pixel_skip; - pixel_countdown -= pixel_skip; - byte_run = buf[stream_ptr++]; - if (byte_run < 0) { - byte_run = -byte_run; - palette_idx1 = buf[stream_ptr++]; - palette_idx2 = buf[stream_ptr++]; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { - pixels[pixel_ptr++] = palette_idx1; - pixels[pixel_ptr++] = palette_idx2; - } - } else { - CHECK_PIXEL_PTR(byte_run * 2); - for (j = 0; j < byte_run * 2; j++, pixel_countdown--) { - palette_idx1 = buf[stream_ptr++]; - pixels[pixel_ptr++] = palette_idx1; - } - } - } - - y_ptr += s->frame.linesize[0]; - } - } - break; - - case FLI_LC: - /* line compressed */ - starting_line = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - y_ptr = 0; - y_ptr += starting_line * s->frame.linesize[0]; - - compressed_lines = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - while (compressed_lines > 0) { - pixel_ptr = y_ptr; - pixel_countdown = s->avctx->width; - line_packets = buf[stream_ptr++]; - if (line_packets > 0) { - for (i = 0; i < line_packets; i++) { - /* account for the skip bytes */ - pixel_skip = buf[stream_ptr++]; - pixel_ptr += pixel_skip; - pixel_countdown -= pixel_skip; - byte_run = buf[stream_ptr++]; - if (byte_run > 0) { - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++, pixel_countdown--) { - palette_idx1 = buf[stream_ptr++]; - pixels[pixel_ptr++] = palette_idx1; - } - } else { - byte_run = -byte_run; - palette_idx1 = buf[stream_ptr++]; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++, pixel_countdown--) { - pixels[pixel_ptr++] = palette_idx1; - } - } - } - } - - y_ptr += s->frame.linesize[0]; - compressed_lines--; - } - break; - - case FLI_BLACK: - /* set the whole frame to color 0 (which is usually black) */ - memset(pixels, 0, - s->frame.linesize[0] * s->avctx->height); - break; - - case FLI_BRUN: - /* Byte run compression: This chunk type only occurs in the first - * FLI frame and it will update the entire frame. */ - y_ptr = 0; - for (lines = 0; lines < s->avctx->height; lines++) { - pixel_ptr = y_ptr; - /* disregard the line packets; instead, iterate through all - * pixels on a row */ - stream_ptr++; - pixel_countdown = s->avctx->width; - while (pixel_countdown > 0) { - byte_run = buf[stream_ptr++]; - if (byte_run > 0) { - palette_idx1 = buf[stream_ptr++]; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++) { - pixels[pixel_ptr++] = palette_idx1; - pixel_countdown--; - if (pixel_countdown < 0) - av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", - pixel_countdown); - } - } else { /* copy bytes if byte_run < 0 */ - byte_run = -byte_run; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++) { - palette_idx1 = buf[stream_ptr++]; - pixels[pixel_ptr++] = palette_idx1; - pixel_countdown--; - if (pixel_countdown < 0) - av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", - pixel_countdown); - } - } - } - - y_ptr += s->frame.linesize[0]; - } - break; - - case FLI_COPY: - /* copy the chunk (uncompressed frame) */ - if (chunk_size - 6 > s->avctx->width * s->avctx->height) { - av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ - "bigger than image, skipping chunk\n", chunk_size - 6); - stream_ptr += chunk_size - 6; - } else { - for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height; - y_ptr += s->frame.linesize[0]) { - memcpy(&pixels[y_ptr], &buf[stream_ptr], - s->avctx->width); - stream_ptr += s->avctx->width; - } - } - break; - - case FLI_MINI: - /* some sort of a thumbnail? disregard this chunk... */ - stream_ptr += chunk_size - 6; - break; - - default: - av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); - break; - } - - frame_size -= chunk_size; - num_chunks--; - } - - /* by the end of the chunk, the stream ptr should equal the frame - * size (minus 1, possibly); if it doesn't, issue a warning */ - if ((stream_ptr != buf_size) && (stream_ptr != buf_size - 1)) - av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ - "and final chunk ptr = %d\n", buf_size, stream_ptr); - - /* make the palette available on the way out */ - memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); - if (s->new_palette) { - s->frame.palette_has_changed = 1; - s->new_palette = 0; - } - - *data_size=sizeof(AVFrame); - *(AVFrame*)data = s->frame; - - return buf_size; -} - -static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - /* Note, the only difference between the 15Bpp and 16Bpp */ - /* Format is the pixel format, the packets are processed the same. */ - FlicDecodeContext *s = (FlicDecodeContext *)avctx->priv_data; - - int stream_ptr = 0; - int pixel_ptr; - unsigned char palette_idx1; - - unsigned int frame_size; - int num_chunks; - - unsigned int chunk_size; - int chunk_type; - - int i, j; - - int lines; - int compressed_lines; - signed short line_packets; - int y_ptr; - signed char byte_run; - int pixel_skip; - int pixel_countdown; - unsigned char *pixels; - int pixel; - int pixel_limit; - - s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &s->frame) < 0) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; - } - - pixels = s->frame.data[0]; - pixel_limit = s->avctx->height * s->frame.linesize[0]; - - frame_size = LE_32(&buf[stream_ptr]); - stream_ptr += 6; /* skip the magic number */ - num_chunks = LE_16(&buf[stream_ptr]); - stream_ptr += 10; /* skip padding */ - - frame_size -= 16; - - /* iterate through the chunks */ - while ((frame_size > 0) && (num_chunks > 0)) { - chunk_size = LE_32(&buf[stream_ptr]); - stream_ptr += 4; - chunk_type = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - - switch (chunk_type) { - case FLI_256_COLOR: - case FLI_COLOR: - /* For some reason, it seems that non-paletised flics do include one of these */ - /* chunks in their first frame. Why i do not know, it seems rather extraneous */ -/* av_log(avctx, AV_LOG_ERROR, "Unexpected Palette chunk %d in non-paletised FLC\n",chunk_type);*/ - stream_ptr = stream_ptr + chunk_size - 6; - break; - - case FLI_DELTA: - case FLI_DTA_LC: - y_ptr = 0; - compressed_lines = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - while (compressed_lines > 0) { - line_packets = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - if (line_packets < 0) { - line_packets = -line_packets; - y_ptr += line_packets * s->frame.linesize[0]; - } else { - compressed_lines--; - pixel_ptr = y_ptr; - pixel_countdown = s->avctx->width; - for (i = 0; i < line_packets; i++) { - /* account for the skip bytes */ - pixel_skip = buf[stream_ptr++]; - pixel_ptr += (pixel_skip*2); /* Pixel is 2 bytes wide */ - pixel_countdown -= pixel_skip; - byte_run = buf[stream_ptr++]; - if (byte_run < 0) { - byte_run = -byte_run; - pixel = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { - *((signed short*)(&pixels[pixel_ptr])) = pixel; - pixel_ptr += 2; - } - } else { - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++, pixel_countdown--) { - *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - pixel_ptr += 2; - } - } - } - - y_ptr += s->frame.linesize[0]; - } - } - break; - - case FLI_LC: - av_log(avctx, AV_LOG_ERROR, "Unexpected FLI_LC chunk in non-paletised FLC\n"); - stream_ptr = stream_ptr + chunk_size - 6; - break; - - case FLI_BLACK: - /* set the whole frame to 0x0000 which is balck in both 15Bpp and 16Bpp modes. */ - memset(pixels, 0x0000, - s->frame.linesize[0] * s->avctx->height * 2); - break; - - case FLI_BRUN: - y_ptr = 0; - for (lines = 0; lines < s->avctx->height; lines++) { - pixel_ptr = y_ptr; - /* disregard the line packets; instead, iterate through all - * pixels on a row */ - stream_ptr++; - pixel_countdown = (s->avctx->width * 2); - - while (pixel_countdown > 0) { - byte_run = buf[stream_ptr++]; - if (byte_run > 0) { - palette_idx1 = buf[stream_ptr++]; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++) { - pixels[pixel_ptr++] = palette_idx1; - pixel_countdown--; - if (pixel_countdown < 0) - av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", - pixel_countdown); - } - } else { /* copy bytes if byte_run < 0 */ - byte_run = -byte_run; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++) { - palette_idx1 = buf[stream_ptr++]; - pixels[pixel_ptr++] = palette_idx1; - pixel_countdown--; - if (pixel_countdown < 0) - av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", - pixel_countdown); - } - } - } - - /* Now FLX is strange, in that it is "byte" as opposed to "pixel" run length compressed. - * This doesnt give us any good oportunity to perform word endian conversion - * during decompression. So if its requried (ie, this isnt a LE target, we do - * a second pass over the line here, swapping the bytes. - */ - pixel = 0xFF00; - if (0xFF00 != LE_16(&pixel)) /* Check if its not an LE Target */ - { - pixel_ptr = y_ptr; - pixel_countdown = s->avctx->width; - while (pixel_countdown > 0) { - *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[pixel_ptr]); - pixel_ptr += 2; - } - } - y_ptr += s->frame.linesize[0]; - } - break; - - case FLI_DTA_BRUN: - y_ptr = 0; - for (lines = 0; lines < s->avctx->height; lines++) { - pixel_ptr = y_ptr; - /* disregard the line packets; instead, iterate through all - * pixels on a row */ - stream_ptr++; - pixel_countdown = s->avctx->width; /* Width is in pixels, not bytes */ - - while (pixel_countdown > 0) { - byte_run = buf[stream_ptr++]; - if (byte_run > 0) { - pixel = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++) { - *((signed short*)(&pixels[pixel_ptr])) = pixel; - pixel_ptr += 2; - pixel_countdown--; - if (pixel_countdown < 0) - av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", - pixel_countdown); - } - } else { /* copy pixels if byte_run < 0 */ - byte_run = -byte_run; - CHECK_PIXEL_PTR(byte_run); - for (j = 0; j < byte_run; j++) { - *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]); - stream_ptr += 2; - pixel_ptr += 2; - pixel_countdown--; - if (pixel_countdown < 0) - av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", - pixel_countdown); - } - } - } - - y_ptr += s->frame.linesize[0]; - } - break; - - case FLI_COPY: - case FLI_DTA_COPY: - /* copy the chunk (uncompressed frame) */ - if (chunk_size - 6 > (unsigned int)(s->avctx->width * s->avctx->height)*2) { - av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ - "bigger than image, skipping chunk\n", chunk_size - 6); - stream_ptr += chunk_size - 6; - } else { - - for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height; - y_ptr += s->frame.linesize[0]) { - - pixel_countdown = s->avctx->width; - pixel_ptr = 0; - while (pixel_countdown > 0) { - *((signed short*)(&pixels[y_ptr + pixel_ptr])) = LE_16(&buf[stream_ptr+pixel_ptr]); - pixel_ptr += 2; - pixel_countdown--; - } - stream_ptr += s->avctx->width*2; - } - } - break; - - case FLI_MINI: - /* some sort of a thumbnail? disregard this chunk... */ - stream_ptr += chunk_size - 6; - break; - - default: - av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); - break; - } - - frame_size -= chunk_size; - num_chunks--; - } - - /* by the end of the chunk, the stream ptr should equal the frame - * size (minus 1, possibly); if it doesn't, issue a warning */ - if ((stream_ptr != buf_size) && (stream_ptr != buf_size - 1)) - av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ - "and final chunk ptr = %d\n", buf_size, stream_ptr); - - - *data_size=sizeof(AVFrame); - *(AVFrame*)data = s->frame; - - return buf_size; -} - -static int flic_decode_frame_24BPP(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - av_log(avctx, AV_LOG_ERROR, "24Bpp FLC Unsupported due to lack of test files.\n"); - return -1; -} - -static int flic_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - if (avctx->pix_fmt == PIX_FMT_PAL8) { - return flic_decode_frame_8BPP(avctx, data, data_size, - buf, buf_size); - } - else if ((avctx->pix_fmt == PIX_FMT_RGB555) || - (avctx->pix_fmt == PIX_FMT_RGB565)) { - return flic_decode_frame_15_16BPP(avctx, data, data_size, - buf, buf_size); - } - else if (avctx->pix_fmt == PIX_FMT_BGR24) { - return flic_decode_frame_24BPP(avctx, data, data_size, - buf, buf_size); - } - - /* Shouldnt get here, ever as the pix_fmt is processed */ - /* in flic_decode_init and the above if should deal with */ - /* the finite set of possibilites allowable by here. */ - /* but in case we do, just error out. */ - av_log(avctx, AV_LOG_ERROR, "Unknown Format of FLC. My Science cant explain how this happened\n"); - return -1; -} - - -static int flic_decode_end(AVCodecContext *avctx) -{ - FlicDecodeContext *s = avctx->priv_data; - - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); - - return 0; -} - -AVCodec flic_decoder = { - "flic", - CODEC_TYPE_VIDEO, - CODEC_ID_FLIC, - sizeof(FlicDecodeContext), - flic_decode_init, - NULL, - flic_decode_end, - flic_decode_frame, - CODEC_CAP_DR1, - NULL, - NULL, - NULL, - NULL -};
--- a/src/ffmpeg/libavcodec/msrle.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,309 +0,0 @@ -/* - * Micrsoft RLE Video Decoder - * Copyright (C) 2003 the ffmpeg project - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file msrle.c - * MS RLE Video Decoder by Mike Melanson (melanson@pcisys.net) - * For more information about the MS RLE format, visit: - * http://www.pcisys.net/~melanson/codecs/ - * - * The MS RLE decoder outputs PAL8 colorspace data. - * - * Note that this decoder expects the palette colors from the end of the - * BITMAPINFO header passed through palctrl. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" - -typedef struct MsrleContext { - AVCodecContext *avctx; - AVFrame frame; - - unsigned char *buf; - int size; - -} MsrleContext; - -#define FETCH_NEXT_STREAM_BYTE() \ - if (stream_ptr >= s->size) \ - { \ - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: stream ptr just went out of bounds (1)\n"); \ - return; \ - } \ - stream_byte = s->buf[stream_ptr++]; - -static void msrle_decode_pal4(MsrleContext *s) -{ - int stream_ptr = 0; - unsigned char rle_code; - unsigned char extra_byte, odd_pixel; - unsigned char stream_byte; - int pixel_ptr = 0; - int row_dec = s->frame.linesize[0]; - int row_ptr = (s->avctx->height - 1) * row_dec; - int frame_size = row_dec * s->avctx->height; - int i; - - /* make the palette available */ - memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); - if (s->avctx->palctrl->palette_changed) { - s->frame.palette_has_changed = 1; - s->avctx->palctrl->palette_changed = 0; - } - - while (row_ptr >= 0) { - FETCH_NEXT_STREAM_BYTE(); - rle_code = stream_byte; - if (rle_code == 0) { - /* fetch the next byte to see how to handle escape code */ - FETCH_NEXT_STREAM_BYTE(); - if (stream_byte == 0) { - /* line is done, goto the next one */ - row_ptr -= row_dec; - pixel_ptr = 0; - } else if (stream_byte == 1) { - /* decode is done */ - return; - } else if (stream_byte == 2) { - /* reposition frame decode coordinates */ - FETCH_NEXT_STREAM_BYTE(); - pixel_ptr += stream_byte; - FETCH_NEXT_STREAM_BYTE(); - row_ptr -= stream_byte * row_dec; - } else { - // copy pixels from encoded stream - odd_pixel = stream_byte & 1; - rle_code = (stream_byte + 1) / 2; - extra_byte = rle_code & 0x01; - if ((row_ptr + pixel_ptr + stream_byte > frame_size) || - (row_ptr < 0)) { - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n"); - return; - } - - for (i = 0; i < rle_code; i++) { - if (pixel_ptr >= s->avctx->width) - break; - FETCH_NEXT_STREAM_BYTE(); - s->frame.data[0][row_ptr + pixel_ptr] = stream_byte >> 4; - pixel_ptr++; - if (i + 1 == rle_code && odd_pixel) - break; - if (pixel_ptr >= s->avctx->width) - break; - s->frame.data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F; - pixel_ptr++; - } - - // if the RLE code is odd, skip a byte in the stream - if (extra_byte) - stream_ptr++; - } - } else { - // decode a run of data - if ((row_ptr + pixel_ptr + stream_byte > frame_size) || - (row_ptr < 0)) { - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n"); - return; - } - FETCH_NEXT_STREAM_BYTE(); - for (i = 0; i < rle_code; i++) { - if (pixel_ptr >= s->avctx->width) - break; - if ((i & 1) == 0) - s->frame.data[0][row_ptr + pixel_ptr] = stream_byte >> 4; - else - s->frame.data[0][row_ptr + pixel_ptr] = stream_byte & 0x0F; - pixel_ptr++; - } - } - } - - /* one last sanity check on the way out */ - if (stream_ptr < s->size) - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: ended frame decode with bytes left over (%d < %d)\n", - stream_ptr, s->size); -} - - - -static void msrle_decode_pal8(MsrleContext *s) -{ - int stream_ptr = 0; - unsigned char rle_code; - unsigned char extra_byte; - unsigned char stream_byte; - int pixel_ptr = 0; - int row_dec = s->frame.linesize[0]; - int row_ptr = (s->avctx->height - 1) * row_dec; - int frame_size = row_dec * s->avctx->height; - - /* make the palette available */ - memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); - if (s->avctx->palctrl->palette_changed) { - s->frame.palette_has_changed = 1; - s->avctx->palctrl->palette_changed = 0; - } - - while (row_ptr >= 0) { - FETCH_NEXT_STREAM_BYTE(); - rle_code = stream_byte; - if (rle_code == 0) { - /* fetch the next byte to see how to handle escape code */ - FETCH_NEXT_STREAM_BYTE(); - if (stream_byte == 0) { - /* line is done, goto the next one */ - row_ptr -= row_dec; - pixel_ptr = 0; - } else if (stream_byte == 1) { - /* decode is done */ - return; - } else if (stream_byte == 2) { - /* reposition frame decode coordinates */ - FETCH_NEXT_STREAM_BYTE(); - pixel_ptr += stream_byte; - FETCH_NEXT_STREAM_BYTE(); - row_ptr -= stream_byte * row_dec; - } else { - /* copy pixels from encoded stream */ - if ((row_ptr + pixel_ptr + stream_byte > frame_size) || - (row_ptr < 0)) { - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (1)\n"); - return; - } - - rle_code = stream_byte; - extra_byte = stream_byte & 0x01; - if (stream_ptr + rle_code + extra_byte > s->size) { - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: stream ptr just went out of bounds (2)\n"); - return; - } - - while (rle_code--) { - FETCH_NEXT_STREAM_BYTE(); - s->frame.data[0][row_ptr + pixel_ptr] = stream_byte; - pixel_ptr++; - } - - /* if the RLE code is odd, skip a byte in the stream */ - if (extra_byte) - stream_ptr++; - } - } else { - /* decode a run of data */ - if ((row_ptr + pixel_ptr + stream_byte > frame_size) || - (row_ptr < 0)) { - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: frame ptr just went out of bounds (2)\n"); - return; - } - - FETCH_NEXT_STREAM_BYTE(); - - while(rle_code--) { - s->frame.data[0][row_ptr + pixel_ptr] = stream_byte; - pixel_ptr++; - } - } - } - - /* one last sanity check on the way out */ - if (stream_ptr < s->size) - av_log(s->avctx, AV_LOG_ERROR, " MS RLE: ended frame decode with bytes left over (%d < %d)\n", - stream_ptr, s->size); -} - -static int msrle_decode_init(AVCodecContext *avctx) -{ - MsrleContext *s = (MsrleContext *)avctx->priv_data; - - s->avctx = avctx; - - avctx->pix_fmt = PIX_FMT_PAL8; - avctx->has_b_frames = 0; - s->frame.data[0] = NULL; - - return 0; -} - -static int msrle_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - MsrleContext *s = (MsrleContext *)avctx->priv_data; - - s->buf = buf; - s->size = buf_size; - - s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &s->frame)) { - av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; - } - - switch (avctx->bits_per_sample) { - case 8: - msrle_decode_pal8(s); - break; - case 4: - msrle_decode_pal4(s); - break; - default: - av_log(avctx, AV_LOG_ERROR, "Don't know how to decode depth %u.\n", - avctx->bits_per_sample); - } - - *data_size = sizeof(AVFrame); - *(AVFrame*)data = s->frame; - - /* report that the buffer was completely consumed */ - return buf_size; -} - -static int msrle_decode_end(AVCodecContext *avctx) -{ - MsrleContext *s = (MsrleContext *)avctx->priv_data; - - /* release the last frame */ - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); - - return 0; -} - -AVCodec msrle_decoder = { - "msrle", - CODEC_TYPE_VIDEO, - CODEC_ID_MSRLE, - sizeof(MsrleContext), - msrle_decode_init, - NULL, - msrle_decode_end, - msrle_decode_frame, - CODEC_CAP_DR1, -};
--- a/src/ffmpeg/libavcodec/msvideo1.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,349 +0,0 @@ -/* - * Microsoft Video-1 Decoder - * Copyright (C) 2003 the ffmpeg project - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -/** - * @file msvideo1.c - * Microsoft Video-1 Decoder by Mike Melanson (melanson@pcisys.net) - * For more information about the MS Video-1 format, visit: - * http://www.pcisys.net/~melanson/codecs/ - * - * This decoder outputs either PAL8 or RGB555 data, depending on the - * whether a RGB palette was passed through palctrl; - * if it's present, then the data is PAL8; RGB555 otherwise. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> - -#include "common.h" -#include "avcodec.h" -#include "dsputil.h" - -#define PALETTE_COUNT 256 -#define CHECK_STREAM_PTR(n) \ - if ((stream_ptr + n) > s->size ) { \ - av_log(s->avctx, AV_LOG_ERROR, " MS Video-1 warning: stream_ptr out of bounds (%d >= %d)\n", \ - stream_ptr + n, s->size); \ - return; \ - } - -typedef struct Msvideo1Context { - - AVCodecContext *avctx; - DSPContext dsp; - AVFrame frame; - - unsigned char *buf; - int size; - - int mode_8bit; /* if it's not 8-bit, it's 16-bit */ - -} Msvideo1Context; - -static int msvideo1_decode_init(AVCodecContext *avctx) -{ - Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data; - - s->avctx = avctx; - - /* figure out the colorspace based on the presence of a palette */ - if (s->avctx->palctrl) { - s->mode_8bit = 1; - avctx->pix_fmt = PIX_FMT_PAL8; - } else { - s->mode_8bit = 0; - avctx->pix_fmt = PIX_FMT_RGB555; - } - - avctx->has_b_frames = 0; - dsputil_init(&s->dsp, avctx); - - s->frame.data[0] = NULL; - - return 0; -} - -static void msvideo1_decode_8bit(Msvideo1Context *s) -{ - int block_ptr, pixel_ptr; - int total_blocks; - int pixel_x, pixel_y; /* pixel width and height iterators */ - int block_x, block_y; /* block width and height iterators */ - int blocks_wide, blocks_high; /* width and height in 4x4 blocks */ - int block_inc; - int row_dec; - - /* decoding parameters */ - int stream_ptr; - unsigned char byte_a, byte_b; - unsigned short flags; - int skip_blocks; - unsigned char colors[8]; - unsigned char *pixels = s->frame.data[0]; - int stride = s->frame.linesize[0]; - - stream_ptr = 0; - skip_blocks = 0; - blocks_wide = s->avctx->width / 4; - blocks_high = s->avctx->height / 4; - total_blocks = blocks_wide * blocks_high; - block_inc = 4; - row_dec = stride + 4; - - for (block_y = blocks_high; block_y > 0; block_y--) { - block_ptr = ((block_y * 4) - 1) * stride; - for (block_x = blocks_wide; block_x > 0; block_x--) { - /* check if this block should be skipped */ - if (skip_blocks) { - block_ptr += block_inc; - skip_blocks--; - total_blocks--; - continue; - } - - pixel_ptr = block_ptr; - - /* get the next two bytes in the encoded data stream */ - CHECK_STREAM_PTR(2); - byte_a = s->buf[stream_ptr++]; - byte_b = s->buf[stream_ptr++]; - - /* check if the decode is finished */ - if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) - return; - else if ((byte_b & 0xFC) == 0x84) { - /* skip code, but don't count the current block */ - skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1; - } else if (byte_b < 0x80) { - /* 2-color encoding */ - flags = (byte_b << 8) | byte_a; - - CHECK_STREAM_PTR(2); - colors[0] = s->buf[stream_ptr++]; - colors[1] = s->buf[stream_ptr++]; - - for (pixel_y = 0; pixel_y < 4; pixel_y++) { - for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1]; - pixel_ptr -= row_dec; - } - } else if (byte_b >= 0x90) { - /* 8-color encoding */ - flags = (byte_b << 8) | byte_a; - - CHECK_STREAM_PTR(8); - memcpy(colors, &s->buf[stream_ptr], 8); - stream_ptr += 8; - - for (pixel_y = 0; pixel_y < 4; pixel_y++) { - for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixel_ptr++] = - colors[((pixel_y & 0x2) << 1) + - (pixel_x & 0x2) + ((flags & 0x1) ^ 1)]; - pixel_ptr -= row_dec; - } - } else { - /* 1-color encoding */ - colors[0] = byte_a; - - for (pixel_y = 0; pixel_y < 4; pixel_y++) { - for (pixel_x = 0; pixel_x < 4; pixel_x++) - pixels[pixel_ptr++] = colors[0]; - pixel_ptr -= row_dec; - } - } - - block_ptr += block_inc; - total_blocks--; - } - } - - /* make the palette available on the way out */ - if (s->avctx->pix_fmt == PIX_FMT_PAL8) { - memcpy(s->frame.data[1], s->avctx->palctrl->palette, AVPALETTE_SIZE); - if (s->avctx->palctrl->palette_changed) { - s->frame.palette_has_changed = 1; - s->avctx->palctrl->palette_changed = 0; - } - } -} - -static void msvideo1_decode_16bit(Msvideo1Context *s) -{ - int block_ptr, pixel_ptr; - int total_blocks; - int pixel_x, pixel_y; /* pixel width and height iterators */ - int block_x, block_y; /* block width and height iterators */ - int blocks_wide, blocks_high; /* width and height in 4x4 blocks */ - int block_inc; - int row_dec; - - /* decoding parameters */ - int stream_ptr; - unsigned char byte_a, byte_b; - unsigned short flags; - int skip_blocks; - unsigned short colors[8]; - unsigned short *pixels = (unsigned short *)s->frame.data[0]; - int stride = s->frame.linesize[0] / 2; - - stream_ptr = 0; - skip_blocks = 0; - blocks_wide = s->avctx->width / 4; - blocks_high = s->avctx->height / 4; - total_blocks = blocks_wide * blocks_high; - block_inc = 4; - row_dec = stride + 4; - - for (block_y = blocks_high; block_y > 0; block_y--) { - block_ptr = ((block_y * 4) - 1) * stride; - for (block_x = blocks_wide; block_x > 0; block_x--) { - /* check if this block should be skipped */ - if (skip_blocks) { - block_ptr += block_inc; - skip_blocks--; - total_blocks--; - continue; - } - - pixel_ptr = block_ptr; - - /* get the next two bytes in the encoded data stream */ - CHECK_STREAM_PTR(2); - byte_a = s->buf[stream_ptr++]; - byte_b = s->buf[stream_ptr++]; - - /* check if the decode is finished */ - if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) { - return; - } else if ((byte_b & 0xFC) == 0x84) { - /* skip code, but don't count the current block */ - skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1; - } else if (byte_b < 0x80) { - /* 2- or 8-color encoding modes */ - flags = (byte_b << 8) | byte_a; - - CHECK_STREAM_PTR(4); - colors[0] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - colors[1] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - - if (colors[0] & 0x8000) { - /* 8-color encoding */ - CHECK_STREAM_PTR(12); - colors[2] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - colors[3] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - colors[4] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - colors[5] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - colors[6] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - colors[7] = LE_16(&s->buf[stream_ptr]); - stream_ptr += 2; - - for (pixel_y = 0; pixel_y < 4; pixel_y++) { - for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixel_ptr++] = - colors[((pixel_y & 0x2) << 1) + - (pixel_x & 0x2) + ((flags & 0x1) ^ 1)]; - pixel_ptr -= row_dec; - } - } else { - /* 2-color encoding */ - for (pixel_y = 0; pixel_y < 4; pixel_y++) { - for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1) - pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1]; - pixel_ptr -= row_dec; - } - } - } else { - /* otherwise, it's a 1-color block */ - colors[0] = (byte_b << 8) | byte_a; - - for (pixel_y = 0; pixel_y < 4; pixel_y++) { - for (pixel_x = 0; pixel_x < 4; pixel_x++) - pixels[pixel_ptr++] = colors[0]; - pixel_ptr -= row_dec; - } - } - - block_ptr += block_inc; - total_blocks--; - } - } -} - -static int msvideo1_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data; - - s->buf = buf; - s->size = buf_size; - - s->frame.reference = 1; - s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &s->frame)) { - av_log(s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; - } - - if (s->mode_8bit) - msvideo1_decode_8bit(s); - else - msvideo1_decode_16bit(s); - - *data_size = sizeof(AVFrame); - *(AVFrame*)data = s->frame; - - /* report that the buffer was completely consumed */ - return buf_size; -} - -static int msvideo1_decode_end(AVCodecContext *avctx) -{ - Msvideo1Context *s = (Msvideo1Context *)avctx->priv_data; - - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); - - return 0; -} - -AVCodec msvideo1_decoder = { - "msvideo1", - CODEC_TYPE_VIDEO, - CODEC_ID_MSVIDEO1, - sizeof(Msvideo1Context), - msvideo1_decode_init, - NULL, - msvideo1_decode_end, - msvideo1_decode_frame, - CODEC_CAP_DR1, -};
--- a/src/ffmpeg/libavcodec/raw.c Mon Mar 12 13:58:35 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,206 +0,0 @@ -/* - * Raw Video Codec - * Copyright (c) 2001 Fabrice Bellard. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file raw.c - * Raw Video Codec - */ - -#include "avcodec.h" - -typedef struct RawVideoContext { - unsigned char * buffer; /* block of memory for holding one frame */ - int length; /* number of bytes in buffer */ - AVFrame pic; ///< AVCodecContext.coded_frame -} RawVideoContext; - -typedef struct PixelFormatTag { - int pix_fmt; - unsigned int fourcc; -} PixelFormatTag; - -const PixelFormatTag pixelFormatTags[] = { - { PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */ - { PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') }, - { PIX_FMT_YUV420P, MKTAG('Y', 'V', '1', '2') }, - { PIX_FMT_YUV410P, MKTAG('Y', 'U', 'V', '9') }, - { PIX_FMT_YUV411P, MKTAG('Y', '4', '1', 'B') }, - { PIX_FMT_YUV422P, MKTAG('Y', '4', '2', 'B') }, - { PIX_FMT_GRAY8, MKTAG('Y', '8', '0', '0') }, - { PIX_FMT_GRAY8, MKTAG(' ', ' ', 'Y', '8') }, - - - { PIX_FMT_YUV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */ - { PIX_FMT_YUV422, MKTAG('Y', '4', '2', '2') }, - { PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') }, - { PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') }, - - /* quicktime */ - { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') }, - - { -1, 0 }, -}; - -static int findPixelFormat(unsigned int fourcc) -{ - const PixelFormatTag * tags = pixelFormatTags; - while (tags->pix_fmt >= 0) { - if (tags->fourcc == fourcc) - return tags->pix_fmt; - tags++; - } - return PIX_FMT_YUV420P; -} - -unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat fmt) -{ - const PixelFormatTag * tags = pixelFormatTags; - while (tags->pix_fmt >= 0) { - if (tags->pix_fmt == fmt) - return tags->fourcc; - tags++; - } - return 0; -} - -/* RAW Decoder Implementation */ - -static int raw_init_decoder(AVCodecContext *avctx) -{ - RawVideoContext *context = avctx->priv_data; - - if (avctx->codec_tag) - avctx->pix_fmt = findPixelFormat(avctx->codec_tag); - else if (avctx->bits_per_sample){ - switch(avctx->bits_per_sample){ - case 8: avctx->pix_fmt= PIX_FMT_PAL8 ; break; - case 15: avctx->pix_fmt= PIX_FMT_RGB555; break; - case 16: avctx->pix_fmt= PIX_FMT_RGB565; break; - case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break; - case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break; - } - } - - context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); - context->buffer = av_malloc(context->length); - context->pic.pict_type = FF_I_TYPE; - context->pic.key_frame = 1; - - avctx->coded_frame= &context->pic; - - if (!context->buffer) - return -1; - - return 0; -} - -static void flip(AVCodecContext *avctx, AVPicture * picture){ - if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[2]==0){ - picture->data[0] += picture->linesize[0] * (avctx->height-1); - picture->linesize[0] *= -1; - } -} - -static int raw_decode(AVCodecContext *avctx, - void *data, int *data_size, - uint8_t *buf, int buf_size) -{ - RawVideoContext *context = avctx->priv_data; - - AVFrame * frame = (AVFrame *) data; - AVPicture * picture = (AVPicture *) data; - - frame->interlaced_frame = avctx->coded_frame->interlaced_frame; - frame->top_field_first = avctx->coded_frame->top_field_first; - - if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) - return -1; - - avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); - if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){ - frame->data[1]= context->buffer; - } - if (avctx->palctrl && avctx->palctrl->palette_changed) { - memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); - avctx->palctrl->palette_changed = 0; - } - - flip(avctx, picture); - - if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2')) - { - // swap fields - unsigned char *tmp = picture->data[1]; - picture->data[1] = picture->data[2]; - picture->data[2] = tmp; - } - - *data_size = sizeof(AVPicture); - return buf_size; -} - -static int raw_close_decoder(AVCodecContext *avctx) -{ - RawVideoContext *context = avctx->priv_data; - - av_freep(&context->buffer); - return 0; -} - -/* RAW Encoder Implementation */ -#ifdef CONFIG_RAWVIDEO_ENCODER -static int raw_init_encoder(AVCodecContext *avctx) -{ - avctx->coded_frame = (AVFrame *)avctx->priv_data; - avctx->coded_frame->pict_type = FF_I_TYPE; - avctx->coded_frame->key_frame = 1; - if(!avctx->codec_tag) - avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt); - return 0; -} - -static int raw_encode(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) -{ - return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width, - avctx->height, frame, buf_size); -} - -AVCodec rawvideo_encoder = { - "rawvideo", - CODEC_TYPE_VIDEO, - CODEC_ID_RAWVIDEO, - sizeof(AVFrame), - raw_init_encoder, - raw_encode, -}; -#endif // CONFIG_RAWVIDEO_ENCODER - -AVCodec rawvideo_decoder = { - "rawvideo", - CODEC_TYPE_VIDEO, - CODEC_ID_RAWVIDEO, - sizeof(RawVideoContext), - raw_init_decoder, - NULL, - raw_close_decoder, - raw_decode, -};
--- a/src/ffmpeg/libavcodec/utils.c Mon Mar 12 13:58:35 2007 -0700 +++ b/src/ffmpeg/libavcodec/utils.c Mon Mar 12 14:02:32 2007 -0700 @@ -62,6 +62,109 @@ 0x0F,0x8F,0x4F,0xCF,0x2F,0xAF,0x6F,0xEF,0x1F,0x9F,0x5F,0xDF,0x3F,0xBF,0x7F,0xFF, }; +int av_get_bits_per_sample(enum CodecID codec_id){ + switch(codec_id){ + case CODEC_ID_ADPCM_SBPRO_2: + return 2; + case CODEC_ID_ADPCM_SBPRO_3: + return 3; + case CODEC_ID_ADPCM_SBPRO_4: + case CODEC_ID_ADPCM_CT: + return 4; + case CODEC_ID_PCM_ALAW: + case CODEC_ID_PCM_MULAW: + case CODEC_ID_PCM_S8: + case CODEC_ID_PCM_U8: + return 8; + case CODEC_ID_PCM_S16BE: + case CODEC_ID_PCM_S16LE: + case CODEC_ID_PCM_U16BE: + case CODEC_ID_PCM_U16LE: + return 16; + case CODEC_ID_PCM_S24DAUD: + case CODEC_ID_PCM_S24BE: + case CODEC_ID_PCM_S24LE: + case CODEC_ID_PCM_U24BE: + case CODEC_ID_PCM_U24LE: + return 24; + case CODEC_ID_PCM_S32BE: + case CODEC_ID_PCM_S32LE: + case CODEC_ID_PCM_U32BE: + case CODEC_ID_PCM_U32LE: + return 32; + default: + return 0; + } +} + +/** + * decode a frame. + * @param buf bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE larger then the actual read bytes + * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end + * @param buf_size the size of the buffer in bytes + * @param got_picture_ptr zero if no frame could be decompressed, Otherwise, it is non zero + * @return -1 if error, otherwise return the number of + * bytes used. + */ +int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + uint8_t *buf, int buf_size) +{ + int ret; + + *got_picture_ptr= 0; + if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height)) + return -1; + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ + ret = avctx->codec->decode(avctx, picture, got_picture_ptr, + buf, buf_size); + + emms_c(); //needed to avoid an emms_c() call before every return; + + if (*got_picture_ptr) + avctx->frame_number++; + }else + ret= 0; + + return ret; +} + +/* decode an audio frame. return -1 if error, otherwise return the + *number of bytes used. If no frame could be decompressed, + *frame_size_ptr is zero. Otherwise, it is the decompressed frame + *size in BYTES. */ +int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + uint8_t *buf, int buf_size) +{ + int ret; + + *frame_size_ptr= 0; + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ + ret = avctx->codec->decode(avctx, samples, frame_size_ptr, + buf, buf_size); + avctx->frame_number++; + }else + ret= 0; + return ret; +} + +/* decode a subtitle message. return -1 if error, otherwise return the + *number of bytes used. If no subtitle could be decompressed, + *got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ +int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + const uint8_t *buf, int buf_size) +{ + int ret; + + *got_sub_ptr = 0; + ret = avctx->codec->decode(avctx, sub, got_sub_ptr, + (uint8_t *)buf, buf_size); + if (*got_sub_ptr) + avctx->frame_number++; + return ret; +} #define INTERNAL_BUFFER_SIZE 32 @@ -224,21 +327,6 @@ return ret; } -/* decode an audio frame. return -1 if error, otherwise return the - *number of bytes used. If no frame could be decompressed, - *frame_size_ptr is zero. Otherwise, it is the decompressed frame - *size in BYTES. */ -int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, - int *frame_size_ptr, - uint8_t *buf, int buf_size) -{ - int ret; - ret = avctx->codec->decode(avctx, samples, frame_size_ptr, - buf, buf_size); - avctx->frame_number++; - return ret; -} - int avcodec_close(AVCodecContext *avctx) { if (avctx->codec->close)
--- a/src/ffmpeg/libavformat/Makefile Mon Mar 12 13:58:35 2007 -0700 +++ b/src/ffmpeg/libavformat/Makefile Mon Mar 12 14:02:32 2007 -0700 @@ -27,7 +27,7 @@ dsicin.c jpeg.c pnm.c wv.c \ matroska.c psxstr.c yuv.c \ mm.c raw.c yuv4mpeg.c \ -dv.c dvenc.c mmf.c riff.c +mmf.c riff.c CFLAGS+= $(PICFLAGS) -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -c -I../../.. -I../libavcodec -I../libavformat -I../libavutil -I.. -DHAVE_AV_CONFIG_H