summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libffmpeg/libavcodec/common.c292
-rw-r--r--src/libffmpeg/libavcodec/opts.c208
2 files changed, 0 insertions, 500 deletions
diff --git a/src/libffmpeg/libavcodec/common.c b/src/libffmpeg/libavcodec/common.c
deleted file mode 100644
index 72172fa4f..000000000
--- a/src/libffmpeg/libavcodec/common.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Common bit i/o utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
- * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
- *
- * This library 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 of the License, or (at your option) any later version.
- *
- * This library 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 this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
- */
-
-/**
- * @file common.c
- * common internal api.
- */
-
-#include "avcodec.h"
-
-const uint8_t ff_sqrt_tab[128]={
- 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
- 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 8, 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, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
-};
-
-const uint8_t ff_log2_tab[256]={
- 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
- 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
- 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
-};
-
-void align_put_bits(PutBitContext *s)
-{
-#ifdef ALT_BITSTREAM_WRITER
- put_bits(s,( - s->index) & 7,0);
-#else
- put_bits(s,s->bit_left & 7,0);
-#endif
-}
-
-void put_string(PutBitContext * pbc, char *s, int put_zero)
-{
- while(*s){
- put_bits(pbc, 8, *s);
- s++;
- }
- if(put_zero)
- put_bits(pbc, 8, 0);
-}
-
-/* bit input functions */
-
-/**
- * reads 0-32 bits.
- */
-unsigned int get_bits_long(GetBitContext *s, int n){
- if(n<=17) return get_bits(s, n);
- else{
- int ret= get_bits(s, 16) << (n-16);
- return ret | get_bits(s, n-16);
- }
-}
-
-/**
- * shows 0-32 bits.
- */
-unsigned int show_bits_long(GetBitContext *s, int n){
- if(n<=17) return show_bits(s, n);
- else{
- GetBitContext gb= *s;
- int ret= get_bits_long(s, n);
- *s= gb;
- return ret;
- }
-}
-
-void align_get_bits(GetBitContext *s)
-{
- int n= (-get_bits_count(s)) & 7;
- if(n) skip_bits(s, n);
-}
-
-int check_marker(GetBitContext *s, const char *msg)
-{
- int bit= get_bits1(s);
- if(!bit)
- av_log(NULL, AV_LOG_INFO, "Marker bit missing %s\n", msg);
-
- return bit;
-}
-
-/* VLC decoding */
-
-//#define DEBUG_VLC
-
-#define GET_DATA(v, table, i, wrap, size) \
-{\
- const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
- switch(size) {\
- case 1:\
- v = *(const uint8_t *)ptr;\
- break;\
- case 2:\
- v = *(const uint16_t *)ptr;\
- break;\
- default:\
- v = *(const uint32_t *)ptr;\
- break;\
- }\
-}
-
-
-static int alloc_table(VLC *vlc, int size)
-{
- int index;
- index = vlc->table_size;
- vlc->table_size += size;
- if (vlc->table_size > vlc->table_allocated) {
- vlc->table_allocated += (1 << vlc->bits);
- vlc->table = av_realloc(vlc->table,
- sizeof(VLC_TYPE) * 2 * vlc->table_allocated);
- if (!vlc->table)
- return -1;
- }
- return index;
-}
-
-static int build_table(VLC *vlc, int table_nb_bits,
- int nb_codes,
- const void *bits, int bits_wrap, int bits_size,
- const void *codes, int codes_wrap, int codes_size,
- uint32_t code_prefix, int n_prefix)
-{
- int i, j, k, n, table_size, table_index, nb, n1, index;
- uint32_t code;
- VLC_TYPE (*table)[2];
-
- table_size = 1 << table_nb_bits;
- table_index = alloc_table(vlc, table_size);
-#ifdef DEBUG_VLC
- printf("new table index=%d size=%d code_prefix=%x n=%d\n",
- table_index, table_size, code_prefix, n_prefix);
-#endif
- if (table_index < 0)
- return -1;
- table = &vlc->table[table_index];
-
- for(i=0;i<table_size;i++) {
- table[i][1] = 0; //bits
- table[i][0] = -1; //codes
- }
-
- /* first pass: map codes and compute auxillary table sizes */
- for(i=0;i<nb_codes;i++) {
- GET_DATA(n, bits, i, bits_wrap, bits_size);
- GET_DATA(code, codes, i, codes_wrap, codes_size);
- /* we accept tables with holes */
- if (n <= 0)
- continue;
-#if defined(DEBUG_VLC) && 0
- printf("i=%d n=%d code=0x%x\n", i, n, code);
-#endif
- /* if code matches the prefix, it is in the table */
- n -= n_prefix;
- if (n > 0 && (code >> n) == code_prefix) {
- if (n <= table_nb_bits) {
- /* no need to add another table */
- j = (code << (table_nb_bits - n)) & (table_size - 1);
- nb = 1 << (table_nb_bits - n);
- for(k=0;k<nb;k++) {
-#ifdef DEBUG_VLC
- av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n",
- j, i, n);
-#endif
- if (table[j][1] /*bits*/ != 0) {
- av_log(NULL, AV_LOG_ERROR, "incorrect codes\n");
- av_abort();
- }
- table[j][1] = n; //bits
- table[j][0] = i; //code
- j++;
- }
- } else {
- n -= table_nb_bits;
- j = (code >> n) & ((1 << table_nb_bits) - 1);
-#ifdef DEBUG_VLC
- printf("%4x: n=%d (subtable)\n",
- j, n);
-#endif
- /* compute table size */
- n1 = -table[j][1]; //bits
- if (n > n1)
- n1 = n;
- table[j][1] = -n1; //bits
- }
- }
- }
-
- /* second pass : fill auxillary tables recursively */
- for(i=0;i<table_size;i++) {
- n = table[i][1]; //bits
- if (n < 0) {
- n = -n;
- if (n > table_nb_bits) {
- n = table_nb_bits;
- table[i][1] = -n; //bits
- }
- index = build_table(vlc, n, nb_codes,
- bits, bits_wrap, bits_size,
- codes, codes_wrap, codes_size,
- (code_prefix << table_nb_bits) | i,
- n_prefix + table_nb_bits);
- if (index < 0)
- return -1;
- /* note: realloc has been done, so reload tables */
- table = &vlc->table[table_index];
- table[i][0] = index; //code
- }
- }
- return table_index;
-}
-
-
-/* Build VLC decoding tables suitable for use with get_vlc().
-
- 'nb_bits' set thee decoding table size (2^nb_bits) entries. The
- bigger it is, the faster is the decoding. But it should not be too
- big to save memory and L1 cache. '9' is a good compromise.
-
- 'nb_codes' : number of vlcs codes
-
- 'bits' : table which gives the size (in bits) of each vlc code.
-
- 'codes' : table which gives the bit pattern of of each vlc code.
-
- 'xxx_wrap' : give the number of bytes between each entry of the
- 'bits' or 'codes' tables.
-
- 'xxx_size' : gives the number of bytes of each entry of the 'bits'
- or 'codes' tables.
-
- 'wrap' and 'size' allows to use any memory configuration and types
- (byte/word/long) to store the 'bits' and 'codes' tables.
-*/
-int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
- const void *bits, int bits_wrap, int bits_size,
- const void *codes, int codes_wrap, int codes_size)
-{
- vlc->bits = nb_bits;
- vlc->table = NULL;
- vlc->table_allocated = 0;
- vlc->table_size = 0;
-#ifdef DEBUG_VLC
- printf("build table nb_codes=%d\n", nb_codes);
-#endif
-
- if (build_table(vlc, nb_bits, nb_codes,
- bits, bits_wrap, bits_size,
- codes, codes_wrap, codes_size,
- 0, 0) < 0) {
- av_free(vlc->table);
- return -1;
- }
- return 0;
-}
-
-
-void free_vlc(VLC *vlc)
-{
- av_free(vlc->table);
-}
-
-int64_t ff_gcd(int64_t a, int64_t b){
- if(b) return ff_gcd(b, a%b);
- else return a;
-}
diff --git a/src/libffmpeg/libavcodec/opts.c b/src/libffmpeg/libavcodec/opts.c
deleted file mode 100644
index 6f8d0c4fd..000000000
--- a/src/libffmpeg/libavcodec/opts.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * LGPL
- */
-
-/**
- * @file opts.c
- * options parser.
- * typical parsed command line:
- * msmpeg4:bitrate=720000:qmax=16
- *
- */
-
-#include "avcodec.h"
-
-const AVOption avoptions_common[] = {
- AVOPTION_CODEC_FLAG("bit_exact", "use only bit-exact stuff", flags, CODEC_FLAG_BITEXACT, 0),
- AVOPTION_CODEC_FLAG("mm_force", "force mm flags", dsp_mask, FF_MM_FORCE, 0),
-#ifdef HAVE_MMX
- AVOPTION_CODEC_FLAG("mm_mmx", "mask MMX feature", dsp_mask, FF_MM_MMX, 0),
- AVOPTION_CODEC_FLAG("mm_3dnow", "mask 3DNow feature", dsp_mask, FF_MM_3DNOW, 0),
- AVOPTION_CODEC_FLAG("mm_mmxext", "mask MMXEXT (MMX2) feature", dsp_mask, FF_MM_MMXEXT, 0),
- AVOPTION_CODEC_FLAG("mm_sse", "mask SSE feature", dsp_mask, FF_MM_SSE, 0),
- AVOPTION_CODEC_FLAG("mm_sse2", "mask SSE2 feature", dsp_mask, FF_MM_SSE2, 0),
-#endif
- AVOPTION_END()
-};
-
-const AVOption avoptions_workaround_bug[] = {
- AVOPTION_CODEC_FLAG("bug_autodetect", "workaround bug autodetection", workaround_bugs, FF_BUG_AUTODETECT, 1),
- AVOPTION_CODEC_FLAG("bug_old_msmpeg4", "workaround old msmpeg4 bug", workaround_bugs, FF_BUG_OLD_MSMPEG4, 0),
- AVOPTION_CODEC_FLAG("bug_xvid_ilace", "workaround XviD interlace bug", workaround_bugs, FF_BUG_XVID_ILACE, 0),
- AVOPTION_CODEC_FLAG("bug_ump4", "workaround ump4 bug", workaround_bugs, FF_BUG_UMP4, 0),
- AVOPTION_CODEC_FLAG("bug_no_padding", "workaround padding bug", workaround_bugs, FF_BUG_NO_PADDING, 0),
- AVOPTION_CODEC_FLAG("bug_ac_vlc", "workaround ac VLC bug", workaround_bugs, FF_BUG_AC_VLC, 0),
- AVOPTION_CODEC_FLAG("bug_qpel_chroma", "workaround qpel chroma bug", workaround_bugs, FF_BUG_QPEL_CHROMA, 0),
- AVOPTION_CODEC_FLAG("bug_std_qpel", "workaround std qpel bug", workaround_bugs, FF_BUG_STD_QPEL, 0),
- AVOPTION_CODEC_FLAG("bug_qpel_chroma2", "workaround qpel chroma2 bug", workaround_bugs, FF_BUG_QPEL_CHROMA2, 0),
- AVOPTION_CODEC_FLAG("bug_direct_blocksize", "workaround direct blocksize bug", workaround_bugs, FF_BUG_DIRECT_BLOCKSIZE, 0),
- AVOPTION_END()
-};
-
-/* avoid compatibility problems by redefining it */
-static int av_strcasecmp(const char *s1, const char *s2)
-{
- signed char val;
-
- for(;;) {
- val = toupper(*s1) - toupper(*s2);
- if (val != 0)
- break;
- if (*s1 != '\0')
- break;
- s1++;
- s2++;
- }
- return val;
-}
-
-
-static int parse_bool(const AVOption *c, char *s, int *var)
-{
- int b = 1; /* by default -on- when present */
- if (s) {
- if (!av_strcasecmp(s, "off") || !av_strcasecmp(s, "false")
- || !strcmp(s, "0"))
- b = 0;
- else if (!av_strcasecmp(s, "on") || !av_strcasecmp(s, "true")
- || !strcmp(s, "1"))
- b = 1;
- else
- return -1;
- }
-
- if (c->type == FF_OPT_TYPE_FLAG) {
- if (b)
- *var |= (int)c->min;
- else
- *var &= ~(int)c->min;
- } else
- *var = b;
- return 0;
-}
-
-static int parse_double(const AVOption *c, char *s, double *var)
-{
- double d;
- if (!s)
- return -1;
- d = atof(s);
- if (c->min != c->max) {
- if (d < c->min || d > c->max) {
- av_log(NULL, AV_LOG_ERROR, "Option: %s double value: %f out of range <%f, %f>\n",
- c->name, d, c->min, c->max);
- return -1;
- }
- }
- *var = d;
- return 0;
-}
-
-static int parse_int(const AVOption* c, char* s, int* var)
-{
- int i;
- if (!s)
- return -1;
- i = atoi(s);
- if (c->min != c->max) {
- if (i < (int)c->min || i > (int)c->max) {
- av_log(NULL, AV_LOG_ERROR, "Option: %s integer value: %d out of range <%d, %d>\n",
- c->name, i, (int)c->min, (int)c->max);
- return -1;
- }
- }
- *var = i;
- return 0;
-}
-
-static int parse_string(const AVOption *c, char *s, void* strct, char **var)
-{
- if (!s)
- return -1;
-
- if (c->type == FF_OPT_TYPE_RCOVERRIDE) {
- int sf, ef, qs;
- float qf;
- if (sscanf(s, "%d,%d,%d,%f", &sf, &ef, &qs, &qf) == 4 && sf < ef) {
- AVCodecContext *avctx = (AVCodecContext *) strct;
- RcOverride *o;
- avctx->rc_override = av_realloc(avctx->rc_override,
- sizeof(RcOverride) * (avctx->rc_override_count + 1));
- o = avctx->rc_override + avctx->rc_override_count++;
- o->start_frame = sf;
- o->end_frame = ef;
- o->qscale = qs;
- o->quality_factor = qf;
-
- //printf("parsed Rc: %d,%d,%d,%f (%d)\n", sf,ef,qs,qf, avctx->rc_override_count);
- } else {
- av_log(NULL, AV_LOG_ERROR, "incorrect/unparsable Rc: \"%s\"\n", s);
- }
- } else
- *var = av_strdup(s);
- return 0;
-}
-
-int avoption_parse(void* strct, const AVOption* list, const char *opts)
-{
- int r = 0;
- char* dopts = av_strdup(opts);
- if (dopts) {
- char *str = dopts;
-
- while (str && *str && r == 0) {
- const AVOption *stack[FF_OPT_MAX_DEPTH];
- const AVOption *c = list;
- int depth = 0;
- char* e = strchr(str, ':');
- char* p;
- if (e)
- *e++ = 0;
-
- p = strchr(str, '=');
- if (p)
- *p++ = 0;
-
- // going through option structures
- for (;;) {
- if (!c->name) {
- if (c->help) {
- stack[depth++] = c;
- c = (const AVOption*) c->help;
- assert(depth > FF_OPT_MAX_DEPTH);
- } else {
- if (depth == 0)
- break; // finished
- c = stack[--depth];
- c++;
- }
- } else {
- if (!strcmp(c->name, str)) {
- void* ptr = (char*)strct + c->offset;
-
- switch (c->type & FF_OPT_TYPE_MASK) {
- case FF_OPT_TYPE_BOOL:
- r = parse_bool(c, p, (int*)ptr);
- break;
- case FF_OPT_TYPE_DOUBLE:
- r = parse_double(c, p, (double*)ptr);
- break;
- case FF_OPT_TYPE_INT:
- r = parse_int(c, p, (int*)ptr);
- break;
- case FF_OPT_TYPE_STRING:
- r = parse_string(c, p, strct, (char**)ptr);
- break;
- default:
- assert(0 == 1);
- }
- }
- c++;
- }
- }
- str = e;
- }
- av_free(dopts);
- }
- return r;
-}