annotate ffmpeg/libavcodec/xface.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * Copyright (c) 1990 James Ashton - Sydney University
yading@10 3 * Copyright (c) 2012 Stefano Sabatini
yading@10 4 *
yading@10 5 * This file is part of FFmpeg.
yading@10 6 *
yading@10 7 * FFmpeg is free software; you can redistribute it and/or
yading@10 8 * modify it under the terms of the GNU Lesser General Public
yading@10 9 * License as published by the Free Software Foundation; either
yading@10 10 * version 2.1 of the License, or (at your option) any later version.
yading@10 11 *
yading@10 12 * FFmpeg is distributed in the hope that it will be useful,
yading@10 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 15 * Lesser General Public License for more details.
yading@10 16 *
yading@10 17 * You should have received a copy of the GNU Lesser General Public
yading@10 18 * License along with FFmpeg; if not, write to the Free Software
yading@10 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 20 */
yading@10 21
yading@10 22 /**
yading@10 23 * @file
yading@10 24 * X-Face common definitions.
yading@10 25 */
yading@10 26
yading@10 27 #include <stdint.h>
yading@10 28
yading@10 29 /* define the face size - 48x48x1 */
yading@10 30 #define XFACE_WIDTH 48
yading@10 31 #define XFACE_HEIGHT 48
yading@10 32 #define XFACE_PIXELS (XFACE_WIDTH * XFACE_HEIGHT)
yading@10 33
yading@10 34 /* compressed output uses the full range of printable characters.
yading@10 35 * In ASCII these are in a contiguous block so we just need to know
yading@10 36 * the first and last. The total number of printables is needed too. */
yading@10 37 #define XFACE_FIRST_PRINT '!'
yading@10 38 #define XFACE_LAST_PRINT '~'
yading@10 39 #define XFACE_PRINTS (XFACE_LAST_PRINT - XFACE_FIRST_PRINT + 1)
yading@10 40
yading@10 41 /*
yading@10 42 * Image is encoded as a big integer, using characters from '~' to
yading@10 43 * '!', for a total of 92 symbols. In order to express 48x48=2304
yading@10 44 * bits, we need a total of 354 digits, as given by:
yading@10 45 * ceil(lg_92(2^2304)) = 354
yading@10 46 */
yading@10 47 #define XFACE_MAX_DIGITS 354
yading@10 48
yading@10 49 #define XFACE_BITSPERWORD 8
yading@10 50 #define XFACE_WORDCARRY (1 << XFACE_BITSPERWORD)
yading@10 51 #define XFACE_WORDMASK (XFACE_WORDCARRY - 1)
yading@10 52
yading@10 53 #define XFACE_MAX_WORDS ((XFACE_PIXELS * 2 + XFACE_BITSPERWORD - 1) / XFACE_BITSPERWORD)
yading@10 54
yading@10 55 /* Portable, very large unsigned integer arithmetic is needed.
yading@10 56 * Implementation uses arrays of WORDs. */
yading@10 57 typedef struct {
yading@10 58 int nb_words;
yading@10 59 uint8_t words[XFACE_MAX_WORDS];
yading@10 60 } BigInt;
yading@10 61
yading@10 62 /**
yading@10 63 * Add a to b storing the result in b.
yading@10 64 */
yading@10 65 void ff_big_add(BigInt *b, uint8_t a);
yading@10 66
yading@10 67 /**
yading@10 68 * Divide b by a storing the result in b and the remainder in the word
yading@10 69 * pointed to by r.
yading@10 70 */
yading@10 71 void ff_big_div(BigInt *b, uint8_t a, uint8_t *r);
yading@10 72
yading@10 73 /**
yading@10 74 * Multiply a by b storing the result in b.
yading@10 75 */
yading@10 76 void ff_big_mul(BigInt *b, uint8_t a);
yading@10 77
yading@10 78 /* Each face is encoded using 9 octrees of 16x16 each. Each level of the
yading@10 79 * trees has varying probabilities of being white, grey or black.
yading@10 80 * The table below is based on sampling many faces */
yading@10 81 enum XFaceColor { XFACE_COLOR_BLACK = 0, XFACE_COLOR_GREY, XFACE_COLOR_WHITE };
yading@10 82
yading@10 83 /* Data of varying probabilities are encoded by a value in the range 0 - 255.
yading@10 84 * The probability of the data determines the range of possible encodings.
yading@10 85 * Offset gives the first possible encoding of the range. */
yading@10 86 typedef struct {
yading@10 87 int range;
yading@10 88 int offset;
yading@10 89 } ProbRange;
yading@10 90
yading@10 91 extern const ProbRange ff_xface_probranges_per_level[4][3];
yading@10 92
yading@10 93 extern const ProbRange ff_xface_probranges_2x2[16];
yading@10 94
yading@10 95 void ff_xface_generate_face(uint8_t *dst, uint8_t * const src);