summaryrefslogtreecommitdiff
path: root/libavcodec/sanm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-04-06 22:00:07 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-04-06 22:19:16 +0200
commit881f4e8d344044956d8ed3ee370e5c1bd882e1a1 (patch)
tree36f3ead18d2f52929b0a72fc0d4a7af7af8fd0a3 /libavcodec/sanm.c
parenta0568ed2544025de3c66dd500811f5ba43f38af4 (diff)
parenta420ccd4f2a011887451a7d5e1bebba4fd7c40e2 (diff)
downloadffmpeg-881f4e8d344044956d8ed3ee370e5c1bd882e1a1.tar.gz
Merge commit 'a420ccd4f2a011887451a7d5e1bebba4fd7c40e2'
* commit 'a420ccd4f2a011887451a7d5e1bebba4fd7c40e2': LucasArts SMUSH SANM video decoder Conflicts: Changelog doc/general.texi libavcodec/Makefile libavcodec/allcodecs.c libavcodec/avcodec.h libavcodec/sanm.c libavcodec/version.h See: 69254f46286099588514454f60fad12f6e51b2cd and others Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/sanm.c')
-rw-r--r--libavcodec/sanm.c504
1 files changed, 362 insertions, 142 deletions
diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c
index a6c1c01e5c..02ef3a5ebe 100644
--- a/libavcodec/sanm.c
+++ b/libavcodec/sanm.c
@@ -20,26 +20,253 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-// #define DEBUG 1
+#include "libavutil/avassert.h"
+#include "libavutil/bswap.h"
+#include "libavutil/imgutils.h"
#include "avcodec.h"
-#include "copy_block.h"
#include "bytestream.h"
+#include "copy_block.h"
#include "internal.h"
-#include "libavutil/bswap.h"
-#include "libavutil/imgutils.h"
-#include "sanm_data.h"
-#include "libavutil/avassert.h"
#define NGLYPHS 256
+#define GLYPH_COORD_VECT_SIZE 16
+#define PALETTE_SIZE 256
+#define PALETTE_DELTA 768
+
+static const int8_t glyph4_x[GLYPH_COORD_VECT_SIZE] = {
+ 0, 1, 2, 3, 3, 3, 3, 2, 1, 0, 0, 0, 1, 2, 2, 1
+};
+
+static const int8_t glyph4_y[GLYPH_COORD_VECT_SIZE] = {
+ 0, 0, 0, 0, 1, 2, 3, 3, 3, 3, 2, 1, 1, 1, 2, 2
+};
+
+static const int8_t glyph8_x[GLYPH_COORD_VECT_SIZE] = {
+ 0, 2, 5, 7, 7, 7, 7, 7, 7, 5, 2, 0, 0, 0, 0, 0
+};
-typedef struct {
+static const int8_t glyph8_y[GLYPH_COORD_VECT_SIZE] = {
+ 0, 0, 0, 0, 1, 3, 4, 6, 7, 7, 7, 7, 6, 4, 3, 1
+};
+
+static const int8_t motion_vectors[256][2] = {
+ { 0, 0 }, { -1, -43 }, { 6, -43 }, { -9, -42 }, { 13, -41 },
+ { -16, -40 }, { 19, -39 }, { -23, -36 }, { 26, -34 }, { -2, -33 },
+ { 4, -33 }, { -29, -32 }, { -9, -32 }, { 11, -31 }, { -16, -29 },
+ { 32, -29 }, { 18, -28 }, { -34, -26 }, { -22, -25 }, { -1, -25 },
+ { 3, -25 }, { -7, -24 }, { 8, -24 }, { 24, -23 }, { 36, -23 },
+ { -12, -22 }, { 13, -21 }, { -38, -20 }, { 0, -20 }, { -27, -19 },
+ { -4, -19 }, { 4, -19 }, { -17, -18 }, { -8, -17 }, { 8, -17 },
+ { 18, -17 }, { 28, -17 }, { 39, -17 }, { -12, -15 }, { 12, -15 },
+ { -21, -14 }, { -1, -14 }, { 1, -14 }, { -41, -13 }, { -5, -13 },
+ { 5, -13 }, { 21, -13 }, { -31, -12 }, { -15, -11 }, { -8, -11 },
+ { 8, -11 }, { 15, -11 }, { -2, -10 }, { 1, -10 }, { 31, -10 },
+ { -23, -9 }, { -11, -9 }, { -5, -9 }, { 4, -9 }, { 11, -9 },
+ { 42, -9 }, { 6, -8 }, { 24, -8 }, { -18, -7 }, { -7, -7 },
+ { -3, -7 }, { -1, -7 }, { 2, -7 }, { 18, -7 }, { -43, -6 },
+ { -13, -6 }, { -4, -6 }, { 4, -6 }, { 8, -6 }, { -33, -5 },
+ { -9, -5 }, { -2, -5 }, { 0, -5 }, { 2, -5 }, { 5, -5 },
+ { 13, -5 }, { -25, -4 }, { -6, -4 }, { -3, -4 }, { 3, -4 },
+ { 9, -4 }, { -19, -3 }, { -7, -3 }, { -4, -3 }, { -2, -3 },
+ { -1, -3 }, { 0, -3 }, { 1, -3 }, { 2, -3 }, { 4, -3 },
+ { 6, -3 }, { 33, -3 }, { -14, -2 }, { -10, -2 }, { -5, -2 },
+ { -3, -2 }, { -2, -2 }, { -1, -2 }, { 0, -2 }, { 1, -2 },
+ { 2, -2 }, { 3, -2 }, { 5, -2 }, { 7, -2 }, { 14, -2 },
+ { 19, -2 }, { 25, -2 }, { 43, -2 }, { -7, -1 }, { -3, -1 },
+ { -2, -1 }, { -1, -1 }, { 0, -1 }, { 1, -1 }, { 2, -1 },
+ { 3, -1 }, { 10, -1 }, { -5, 0 }, { -3, 0 }, { -2, 0 },
+ { -1, 0 }, { 1, 0 }, { 2, 0 }, { 3, 0 }, { 5, 0 },
+ { 7, 0 }, { -10, 1 }, { -7, 1 }, { -3, 1 }, { -2, 1 },
+ { -1, 1 }, { 0, 1 }, { 1, 1 }, { 2, 1 }, { 3, 1 },
+ { -43, 2 }, { -25, 2 }, { -19, 2 }, { -14, 2 }, { -5, 2 },
+ { -3, 2 }, { -2, 2 }, { -1, 2 }, { 0, 2 }, { 1, 2 },
+ { 2, 2 }, { 3, 2 }, { 5, 2 }, { 7, 2 }, { 10, 2 },
+ { 14, 2 }, { -33, 3 }, { -6, 3 }, { -4, 3 }, { -2, 3 },
+ { -1, 3 }, { 0, 3 }, { 1, 3 }, { 2, 3 }, { 4, 3 },
+ { 19, 3 }, { -9, 4 }, { -3, 4 }, { 3, 4 }, { 7, 4 },
+ { 25, 4 }, { -13, 5 }, { -5, 5 }, { -2, 5 }, { 0, 5 },
+ { 2, 5 }, { 5, 5 }, { 9, 5 }, { 33, 5 }, { -8, 6 },
+ { -4, 6 }, { 4, 6 }, { 13, 6 }, { 43, 6 }, { -18, 7 },
+ { -2, 7 }, { 0, 7 }, { 2, 7 }, { 7, 7 }, { 18, 7 },
+ { -24, 8 }, { -6, 8 }, { -42, 9 }, { -11, 9 }, { -4, 9 },
+ { 5, 9 }, { 11, 9 }, { 23, 9 }, { -31, 10 }, { -1, 10 },
+ { 2, 10 }, { -15, 11 }, { -8, 11 }, { 8, 11 }, { 15, 11 },
+ { 31, 12 }, { -21, 13 }, { -5, 13 }, { 5, 13 }, { 41, 13 },
+ { -1, 14 }, { 1, 14 }, { 21, 14 }, { -12, 15 }, { 12, 15 },
+ { -39, 17 }, { -28, 17 }, { -18, 17 }, { -8, 17 }, { 8, 17 },
+ { 17, 18 }, { -4, 19 }, { 0, 19 }, { 4, 19 }, { 27, 19 },
+ { 38, 20 }, { -13, 21 }, { 12, 22 }, { -36, 23 }, { -24, 23 },
+ { -8, 24 }, { 7, 24 }, { -3, 25 }, { 1, 25 }, { 22, 25 },
+ { 34, 26 }, { -18, 28 }, { -32, 29 }, { 16, 29 }, { -11, 31 },
+ { 9, 32 }, { 29, 32 }, { -4, 33 }, { 2, 33 }, { -26, 34 },
+ { 23, 36 }, { -19, 39 }, { 16, 40 }, { -13, 41 }, { 9, 42 },
+ { -6, 43 }, { 1, 43 }, { 0, 0 }, { 0, 0 }, { 0, 0 },
+};
+
+static const int8_t c37_mv[] = {
+ 0, 0, 1, 0, 2, 0, 3, 0, 5, 0,
+ 8, 0, 13, 0, 21, 0, -1, 0, -2, 0,
+ -3, 0, -5, 0, -8, 0, -13, 0, -17, 0,
+ -21, 0, 0, 1, 1, 1, 2, 1, 3, 1,
+ 5, 1, 8, 1, 13, 1, 21, 1, -1, 1,
+ -2, 1, -3, 1, -5, 1, -8, 1, -13, 1,
+ -17, 1, -21, 1, 0, 2, 1, 2, 2, 2,
+ 3, 2, 5, 2, 8, 2, 13, 2, 21, 2,
+ -1, 2, -2, 2, -3, 2, -5, 2, -8, 2,
+ -13, 2, -17, 2, -21, 2, 0, 3, 1, 3,
+ 2, 3, 3, 3, 5, 3, 8, 3, 13, 3,
+ 21, 3, -1, 3, -2, 3, -3, 3, -5, 3,
+ -8, 3, -13, 3, -17, 3, -21, 3, 0, 5,
+ 1, 5, 2, 5, 3, 5, 5, 5, 8, 5,
+ 13, 5, 21, 5, -1, 5, -2, 5, -3, 5,
+ -5, 5, -8, 5, -13, 5, -17, 5, -21, 5,
+ 0, 8, 1, 8, 2, 8, 3, 8, 5, 8,
+ 8, 8, 13, 8, 21, 8, -1, 8, -2, 8,
+ -3, 8, -5, 8, -8, 8, -13, 8, -17, 8,
+ -21, 8, 0, 13, 1, 13, 2, 13, 3, 13,
+ 5, 13, 8, 13, 13, 13, 21, 13, -1, 13,
+ -2, 13, -3, 13, -5, 13, -8, 13, -13, 13,
+ -17, 13, -21, 13, 0, 21, 1, 21, 2, 21,
+ 3, 21, 5, 21, 8, 21, 13, 21, 21, 21,
+ -1, 21, -2, 21, -3, 21, -5, 21, -8, 21,
+ -13, 21, -17, 21, -21, 21, 0, -1, 1, -1,
+ 2, -1, 3, -1, 5, -1, 8, -1, 13, -1,
+ 21, -1, -1, -1, -2, -1, -3, -1, -5, -1,
+ -8, -1, -13, -1, -17, -1, -21, -1, 0, -2,
+ 1, -2, 2, -2, 3, -2, 5, -2, 8, -2,
+ 13, -2, 21, -2, -1, -2, -2, -2, -3, -2,
+ -5, -2, -8, -2, -13, -2, -17, -2, -21, -2,
+ 0, -3, 1, -3, 2, -3, 3, -3, 5, -3,
+ 8, -3, 13, -3, 21, -3, -1, -3, -2, -3,
+ -3, -3, -5, -3, -8, -3, -13, -3, -17, -3,
+ -21, -3, 0, -5, 1, -5, 2, -5, 3, -5,
+ 5, -5, 8, -5, 13, -5, 21, -5, -1, -5,
+ -2, -5, -3, -5, -5, -5, -8, -5, -13, -5,
+ -17, -5, -21, -5, 0, -8, 1, -8, 2, -8,
+ 3, -8, 5, -8, 8, -8, 13, -8, 21, -8,
+ -1, -8, -2, -8, -3, -8, -5, -8, -8, -8,
+ -13, -8, -17, -8, -21, -8, 0, -13, 1, -13,
+ 2, -13, 3, -13, 5, -13, 8, -13, 13, -13,
+ 21, -13, -1, -13, -2, -13, -3, -13, -5, -13,
+ -8, -13, -13, -13, -17, -13, -21, -13, 0, -17,
+ 1, -17, 2, -17, 3, -17, 5, -17, 8, -17,
+ 13, -17, 21, -17, -1, -17, -2, -17, -3, -17,
+ -5, -17, -8, -17, -13, -17, -17, -17, -21, -17,
+ 0, -21, 1, -21, 2, -21, 3, -21, 5, -21,
+ 8, -21, 13, -21, 21, -21, -1, -21, -2, -21,
+ -3, -21, -5, -21, -8, -21, -13, -21, -17, -21,
+ 0, 0, -8, -29, 8, -29, -18, -25, 17, -25,
+ 0, -23, -6, -22, 6, -22, -13, -19, 12, -19,
+ 0, -18, 25, -18, -25, -17, -5, -17, 5, -17,
+ -10, -15, 10, -15, 0, -14, -4, -13, 4, -13,
+ 19, -13, -19, -12, -8, -11, -2, -11, 0, -11,
+ 2, -11, 8, -11, -15, -10, -4, -10, 4, -10,
+ 15, -10, -6, -9, -1, -9, 1, -9, 6, -9,
+ -29, -8, -11, -8, -8, -8, -3, -8, 3, -8,
+ 8, -8, 11, -8, 29, -8, -5, -7, -2, -7,
+ 0, -7, 2, -7, 5, -7, -22, -6, -9, -6,
+ -6, -6, -3, -6, -1, -6, 1, -6, 3, -6,
+ 6, -6, 9, -6, 22, -6, -17, -5, -7, -5,
+ -4, -5, -2, -5, 0, -5, 2, -5, 4, -5,
+ 7, -5, 17, -5, -13, -4, -10, -4, -5, -4,
+ -3, -4, -1, -4, 0, -4, 1, -4, 3, -4,
+ 5, -4, 10, -4, 13, -4, -8, -3, -6, -3,
+ -4, -3, -3, -3, -2, -3, -1, -3, 0, -3,
+ 1, -3, 2, -3, 4, -3, 6, -3, 8, -3,
+ -11, -2, -7, -2, -5, -2, -3, -2, -2, -2,
+ -1, -2, 0, -2, 1, -2, 2, -2, 3, -2,
+ 5, -2, 7, -2, 11, -2, -9, -1, -6, -1,
+ -4, -1, -3, -1, -2, -1, -1, -1, 0, -1,
+ 1, -1, 2, -1, 3, -1, 4, -1, 6, -1,
+ 9, -1, -31, 0, -23, 0, -18, 0, -14, 0,
+ -11, 0, -7, 0, -5, 0, -4, 0, -3, 0,
+ -2, 0, -1, 0, 0, -31, 1, 0, 2, 0,
+ 3, 0, 4, 0, 5, 0, 7, 0, 11, 0,
+ 14, 0, 18, 0, 23, 0, 31, 0, -9, 1,
+ -6, 1, -4, 1, -3, 1, -2, 1, -1, 1,
+ 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
+ 6, 1, 9, 1, -11, 2, -7, 2, -5, 2,
+ -3, 2, -2, 2, -1, 2, 0, 2, 1, 2,
+ 2, 2, 3, 2, 5, 2, 7, 2, 11, 2,
+ -8, 3, -6, 3, -4, 3, -2, 3, -1, 3,
+ 0, 3, 1, 3, 2, 3, 3, 3, 4, 3,
+ 6, 3, 8, 3, -13, 4, -10, 4, -5, 4,
+ -3, 4, -1, 4, 0, 4, 1, 4, 3, 4,
+ 5, 4, 10, 4, 13, 4, -17, 5, -7, 5,
+ -4, 5, -2, 5, 0, 5, 2, 5, 4, 5,
+ 7, 5, 17, 5, -22, 6, -9, 6, -6, 6,
+ -3, 6, -1, 6, 1, 6, 3, 6, 6, 6,
+ 9, 6, 22, 6, -5, 7, -2, 7, 0, 7,
+ 2, 7, 5, 7, -29, 8, -11, 8, -8, 8,
+ -3, 8, 3, 8, 8, 8, 11, 8, 29, 8,
+ -6, 9, -1, 9, 1, 9, 6, 9, -15, 10,
+ -4, 10, 4, 10, 15, 10, -8, 11, -2, 11,
+ 0, 11, 2, 11, 8, 11, 19, 12, -19, 13,
+ -4, 13, 4, 13, 0, 14, -10, 15, 10, 15,
+ -5, 17, 5, 17, 25, 17, -25, 18, 0, 18,
+ -12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
+ -17, 25, 18, 25, -8, 29, 8, 29, 0, 31,
+ 0, 0, -6, -22, 6, -22, -13, -19, 12, -19,
+ 0, -18, -5, -17, 5, -17, -10, -15, 10, -15,
+ 0, -14, -4, -13, 4, -13, 19, -13, -19, -12,
+ -8, -11, -2, -11, 0, -11, 2, -11, 8, -11,
+ -15, -10, -4, -10, 4, -10, 15, -10, -6, -9,
+ -1, -9, 1, -9, 6, -9, -11, -8, -8, -8,
+ -3, -8, 0, -8, 3, -8, 8, -8, 11, -8,
+ -5, -7, -2, -7, 0, -7, 2, -7, 5, -7,
+ -22, -6, -9, -6, -6, -6, -3, -6, -1, -6,
+ 1, -6, 3, -6, 6, -6, 9, -6, 22, -6,
+ -17, -5, -7, -5, -4, -5, -2, -5, -1, -5,
+ 0, -5, 1, -5, 2, -5, 4, -5, 7, -5,
+ 17, -5, -13, -4, -10, -4, -5, -4, -3, -4,
+ -2, -4, -1, -4, 0, -4, 1, -4, 2, -4,
+ 3, -4, 5, -4, 10, -4, 13, -4, -8, -3,
+ -6, -3, -4, -3, -3, -3, -2, -3, -1, -3,
+ 0, -3, 1, -3, 2, -3, 3, -3, 4, -3,
+ 6, -3, 8, -3, -11, -2, -7, -2, -5, -2,
+ -4, -2, -3, -2, -2, -2, -1, -2, 0, -2,
+ 1, -2, 2, -2, 3, -2, 4, -2, 5, -2,
+ 7, -2, 11, -2, -9, -1, -6, -1, -5, -1,
+ -4, -1, -3, -1, -2, -1, -1, -1, 0, -1,
+ 1, -1, 2, -1, 3, -1, 4, -1, 5, -1,
+ 6, -1, 9, -1, -23, 0, -18, 0, -14, 0,
+ -11, 0, -7, 0, -5, 0, -4, 0, -3, 0,
+ -2, 0, -1, 0, 0, -23, 1, 0, 2, 0,
+ 3, 0, 4, 0, 5, 0, 7, 0, 11, 0,
+ 14, 0, 18, 0, 23, 0, -9, 1, -6, 1,
+ -5, 1, -4, 1, -3, 1, -2, 1, -1, 1,
+ 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
+ 5, 1, 6, 1, 9, 1, -11, 2, -7, 2,
+ -5, 2, -4, 2, -3, 2, -2, 2, -1, 2,
+ 0, 2, 1, 2, 2, 2, 3, 2, 4, 2,
+ 5, 2, 7, 2, 11, 2, -8, 3, -6, 3,
+ -4, 3, -3, 3, -2, 3, -1, 3, 0, 3,
+ 1, 3, 2, 3, 3, 3, 4, 3, 6, 3,
+ 8, 3, -13, 4, -10, 4, -5, 4, -3, 4,
+ -2, 4, -1, 4, 0, 4, 1, 4, 2, 4,
+ 3, 4, 5, 4, 10, 4, 13, 4, -17, 5,
+ -7, 5, -4, 5, -2, 5, -1, 5, 0, 5,
+ 1, 5, 2, 5, 4, 5, 7, 5, 17, 5,
+ -22, 6, -9, 6, -6, 6, -3, 6, -1, 6,
+ 1, 6, 3, 6, 6, 6, 9, 6, 22, 6,
+ -5, 7, -2, 7, 0, 7, 2, 7, 5, 7,
+ -11, 8, -8, 8, -3, 8, 0, 8, 3, 8,
+ 8, 8, 11, 8, -6, 9, -1, 9, 1, 9,
+ 6, 9, -15, 10, -4, 10, 4, 10, 15, 10,
+ -8, 11, -2, 11, 0, 11, 2, 11, 8, 11,
+ 19, 12, -19, 13, -4, 13, 4, 13, 0, 14,
+ -10, 15, 10, 15, -5, 17, 5, 17, 0, 18,
+ -12, 19, 13, 19, -6, 22, 6, 22, 0, 23,
+};
+
+typedef struct SANMVideoContext {
AVCodecContext *avctx;
GetByteContext gb;
int version, subversion;
- uint32_t pal[256];
- int16_t delta_pal[768];
+ uint32_t pal[PALETTE_SIZE];
+ int16_t delta_pal[PALETTE_DELTA];
int pitch;
int width, height;
@@ -66,7 +293,7 @@ typedef struct {
int8_t p8x8glyphs[NGLYPHS][64];
} SANMVideoContext;
-typedef struct {
+typedef struct SANMFrameHeader {
int seq_num, codec, rotate_code, rle_output_size;
uint16_t bg_color;
@@ -100,17 +327,16 @@ static enum GlyphEdge which_edge(int x, int y, int edge_size)
{
const int edge_max = edge_size - 1;
- if (!y) {
+ if (!y)
return BOTTOM_EDGE;
- } else if (y == edge_max) {
+ else if (y == edge_max)
return TOP_EDGE;
- } else if (!x) {
+ else if (!x)
return LEFT_EDGE;
- } else if (x == edge_max) {
+ else if (x == edge_max)
return RIGHT_EDGE;
- } else {
+ else
return NO_EDGE;
- }
}
static enum GlyphDir which_direction(enum GlyphEdge edge0, enum GlyphEdge edge1)
@@ -118,27 +344,24 @@ static enum GlyphDir which_direction(enum GlyphEdge edge0, enum GlyphEdge edge1)
if ((edge0 == LEFT_EDGE && edge1 == RIGHT_EDGE) ||
(edge1 == LEFT_EDGE && edge0 == RIGHT_EDGE) ||
(edge0 == BOTTOM_EDGE && edge1 != TOP_EDGE) ||
- (edge1 == BOTTOM_EDGE && edge0 != TOP_EDGE)) {
+ (edge1 == BOTTOM_EDGE && edge0 != TOP_EDGE))
return DIR_UP;
- } else if ((edge0 == TOP_EDGE && edge1 != BOTTOM_EDGE) ||
- (edge1 == TOP_EDGE && edge0 != BOTTOM_EDGE)) {
+ else if ((edge0 == TOP_EDGE && edge1 != BOTTOM_EDGE) ||
+ (edge1 == TOP_EDGE && edge0 != BOTTOM_EDGE))
return DIR_DOWN;
- } else if ((edge0 == LEFT_EDGE && edge1 != RIGHT_EDGE) ||
- (edge1 == LEFT_EDGE && edge0 != RIGHT_EDGE)) {
+ else if ((edge0 == LEFT_EDGE && edge1 != RIGHT_EDGE) ||
+ (edge1 == LEFT_EDGE && edge0 != RIGHT_EDGE))
return DIR_LEFT;
- } else if ((edge0 == TOP_EDGE && edge1 == BOTTOM_EDGE) ||
- (edge1 == TOP_EDGE && edge0 == BOTTOM_EDGE) ||
- (edge0 == RIGHT_EDGE && edge1 != LEFT_EDGE) ||
- (edge1 == RIGHT_EDGE && edge0 != LEFT_EDGE)) {
+ else if ((edge0 == TOP_EDGE && edge1 == BOTTOM_EDGE) ||
+ (edge1 == TOP_EDGE && edge0 == BOTTOM_EDGE) ||
+ (edge0 == RIGHT_EDGE && edge1 != LEFT_EDGE) ||
+ (edge1 == RIGHT_EDGE && edge0 != LEFT_EDGE))
return DIR_RIGHT;
- }
return NO_DIR;
}
-/**
- * Interpolate two points.
- */
+/* Interpolate two points. */
static void interp_point(int8_t *points, int x0, int y0, int x1, int y1,
int pos, int npoints)
{
@@ -152,11 +375,11 @@ static void interp_point(int8_t *points, int x0, int y0, int x1, int y1,
}
/**
- * Construct glyphs by iterating through vectors coordinates.
+ * Construct glyphs by iterating through vector coordinates.
*
* @param pglyphs pointer to table where glyphs are stored
- * @param xvec pointer to x component of vectors coordinates
- * @param yvec pointer to y component of vectors coordinates
+ * @param xvec pointer to x component of vector coordinates
+ * @param yvec pointer to y component of vector coordinates
* @param side_length glyph width/height.
*/
static void make_glyphs(int8_t *pglyphs, const int8_t *xvec, const int8_t *yvec,
@@ -167,15 +390,15 @@ static void make_glyphs(int8_t *pglyphs, const int8_t *xvec, const int8_t *yvec,
int i, j;
for (i = 0; i < GLYPH_COORD_VECT_SIZE; i++) {
- int x0 = xvec[i];
- int y0 = yvec[i];
+ int x0 = xvec[i];
+ int y0 = yvec[i];
enum GlyphEdge edge0 = which_edge(x0, y0, side_length);
for (j = 0; j < GLYPH_COORD_VECT_SIZE; j++, pglyph += glyph_size) {
- int x1 = xvec[j];
- int y1 = yvec[j];
- enum GlyphEdge edge1 = which_edge(x1, y1, side_length);
- enum GlyphDir dir = which_direction(edge0, edge1);
+ int x1 = xvec[j];
+ int y1 = yvec[j];
+ enum GlyphEdge edge1 = which_edge(x1, y1, side_length);
+ enum GlyphDir dir = which_direction(edge0, edge1);
int npoints = FFMAX(FFABS(x1 - x0), FFABS(y1 - y0));
int ipoint;
@@ -217,7 +440,7 @@ static void init_sizes(SANMVideoContext *ctx, int width, int height)
ctx->height = height;
ctx->npixels = width * height;
- ctx->aligned_width = FFALIGN(width, 8);
+ ctx->aligned_width = FFALIGN(width, 8);
ctx->aligned_height = FFALIGN(height, 8);
ctx->buf_size = ctx->aligned_width * ctx->aligned_height * sizeof(ctx->frm0[0]);
@@ -242,9 +465,11 @@ static av_cold int init_buffers(SANMVideoContext *ctx)
av_fast_padded_malloc(&ctx->frm1, &ctx->frm1_size, ctx->buf_size);
av_fast_padded_malloc(&ctx->frm2, &ctx->frm2_size, ctx->buf_size);
if (!ctx->version)
- av_fast_padded_malloc(&ctx->stored_frame, &ctx->stored_frame_size, ctx->buf_size);
+ av_fast_padded_malloc(&ctx->stored_frame,
+ &ctx->stored_frame_size, ctx->buf_size);
- if (!ctx->frm0 || !ctx->frm1 || !ctx->frm2 || (!ctx->stored_frame && !ctx->version)) {
+ if (!ctx->frm0 || !ctx->frm1 || !ctx->frm2 ||
+ (!ctx->stored_frame && !ctx->version)) {
destroy_buffers(ctx);
return AVERROR(ENOMEM);
}
@@ -254,7 +479,6 @@ static av_cold int init_buffers(SANMVideoContext *ctx)
static void rotate_bufs(SANMVideoContext *ctx, int rotate_code)
{
- av_dlog(ctx->avctx, "rotate %d\n", rotate_code);
if (rotate_code == 2)
FFSWAP(uint16_t*, ctx->frm1, ctx->frm2);
FFSWAP(uint16_t*, ctx->frm2, ctx->frm0);
@@ -264,14 +488,14 @@ static av_cold int decode_init(AVCodecContext *avctx)
{
SANMVideoContext *ctx = avctx->priv_data;
- ctx->avctx = avctx;
- ctx->version = !avctx->extradata_size;
+ ctx->avctx = avctx;
+ ctx->version = !avctx->extradata_size;
avctx->pix_fmt = ctx->version ? AV_PIX_FMT_RGB565 : AV_PIX_FMT_PAL8;
init_sizes(ctx, avctx->width, avctx->height);
if (init_buffers(ctx)) {
- av_log(avctx, AV_LOG_ERROR, "error allocating buffers\n");
+ av_log(avctx, AV_LOG_ERROR, "Error allocating buffers.\n");
return AVERROR(ENOMEM);
}
@@ -282,7 +506,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
int i;
if (avctx->extradata_size < 1026) {
- av_log(avctx, AV_LOG_ERROR, "not enough extradata\n");
+ av_log(avctx, AV_LOG_ERROR, "Not enough extradata.\n");
return AVERROR_INVALIDDATA;
}
@@ -332,7 +556,7 @@ static int rle_decode(SANMVideoContext *ctx, uint8_t *dst, const int out_size)
static int old_codec1(SANMVideoContext *ctx, int top,
int left, int width, int height)
{
- uint8_t *dst = ((uint8_t*)ctx->frm0) + left + top * ctx->pitch;
+ uint8_t *dst = ((uint8_t *)ctx->frm0) + left + top * ctx->pitch;
int i, j, len, flag, code, val, pos, end;
for (i = 0; i < height; i++) {
@@ -400,22 +624,21 @@ static int old_codec37(SANMVideoContext *ctx, int top,
{
int stride = ctx->pitch;
int i, j, k, t;
- int skip_run = 0;
- int compr, mvoff, seq, flags;
- uint32_t decoded_size;
uint8_t *dst, *prev;
+ int skip_run = 0;
+ int compr = bytestream2_get_byte(&ctx->gb);
+ int mvoff = bytestream2_get_byte(&ctx->gb);
+ int seq = bytestream2_get_le16(&ctx->gb);
+ uint32_t decoded_size = bytestream2_get_le32(&ctx->gb);
+ int flags;
- compr = bytestream2_get_byte(&ctx->gb);
- mvoff = bytestream2_get_byte(&ctx->gb);
- seq = bytestream2_get_le16(&ctx->gb);
- decoded_size = bytestream2_get_le32(&ctx->gb);
bytestream2_skip(&ctx->gb, 4);
- flags = bytestream2_get_byte(&ctx->gb);
+ flags = bytestream2_get_byte(&ctx->gb);
bytestream2_skip(&ctx->gb, 3);
if (decoded_size > ctx->height * stride - left - top * stride) {
decoded_size = ctx->height * stride - left - top * stride;
- av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n");
+ av_log(ctx->avctx, AV_LOG_WARNING, "Decoded size is too large.\n");
}
ctx->rotate_code = 0;
@@ -427,10 +650,10 @@ static int old_codec37(SANMVideoContext *ctx, int top,
prev = ((uint8_t*)ctx->frm2) + left + top * stride;
if (mvoff > 2) {
- av_log(ctx->avctx, AV_LOG_ERROR, "invalid motion base value %d\n", mvoff);
+ av_log(ctx->avctx, AV_LOG_ERROR, "Invalid motion base value %d.\n", mvoff);
return AVERROR_INVALIDDATA;
}
- av_dlog(ctx->avctx, "compression %d\n", compr);
+
switch (compr) {
case 0:
for (i = 0; i < height; i++) {
@@ -489,7 +712,7 @@ static int old_codec37(SANMVideoContext *ctx, int top,
} else {
int mx, my;
- mx = c37_mv[(mvoff * 255 + code) * 2 ];
+ mx = c37_mv[(mvoff * 255 + code) * 2];
my = c37_mv[(mvoff * 255 + code) * 2 + 1];
codec37_mv(dst + i, prev + i + mx + my * stride,
ctx->height, stride, i + mx, j + my);
@@ -534,8 +757,8 @@ static int old_codec37(SANMVideoContext *ctx, int top,
}
break;
default:
- av_log(ctx->avctx, AV_LOG_ERROR,
- "subcodec 37 compression %d not implemented\n", compr);
+ avpriv_report_missing_feature(ctx->avctx,
+ "Subcodec 37 compression %d", compr);
return AVERROR_PATCHWELCOME;
}
@@ -559,10 +782,10 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1,
if (size == 2) {
if (bytestream2_get_bytes_left(&ctx->gb) < 4)
return AVERROR_INVALIDDATA;
- dst[0] = bytestream2_get_byteu(&ctx->gb);
- dst[1] = bytestream2_get_byteu(&ctx->gb);
- dst[0+stride] = bytestream2_get_byteu(&ctx->gb);
- dst[1+stride] = bytestream2_get_byteu(&ctx->gb);
+ dst[0] = bytestream2_get_byteu(&ctx->gb);
+ dst[1] = bytestream2_get_byteu(&ctx->gb);
+ dst[0 + stride] = bytestream2_get_byteu(&ctx->gb);
+ dst[1 + stride] = bytestream2_get_byteu(&ctx->gb);
} else {
size >>= 1;
if (process_block(ctx, dst, prev1, prev2, stride, tbl, size))
@@ -615,13 +838,13 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1,
} else {
int mx = motion_vectors[code][0];
int my = motion_vectors[code][1];
- int index = prev2 - (const uint8_t*)ctx->frm2;
+ int index = prev2 - (const uint8_t *)ctx->frm2;
- av_assert2(index >= 0 && index < (ctx->buf_size>>1));
+ av_assert2(index >= 0 && index < (ctx->buf_size >> 1));
- if (index < - mx - my*stride ||
- (ctx->buf_size>>1) - index < mx + size + (my + size - 1)*stride) {
- av_log(ctx->avctx, AV_LOG_ERROR, "MV is invalid \n");
+ if (index < -mx - my * stride ||
+ (ctx->buf_size >> 1) - index < mx + size + (my + size - 1) * stride) {
+ av_log(ctx->avctx, AV_LOG_ERROR, "MV is invalid.\n");
return AVERROR_INVALIDDATA;
}
@@ -635,25 +858,25 @@ static int process_block(SANMVideoContext *ctx, uint8_t *dst, uint8_t *prev1,
static int old_codec47(SANMVideoContext *ctx, int top,
int left, int width, int height)
{
- int i, j, seq, compr, new_rot, tbl_pos, skip;
- int stride = ctx->pitch;
- uint8_t *dst = ((uint8_t*)ctx->frm0) + left + top * stride;
- uint8_t *prev1 = (uint8_t*)ctx->frm1;
- uint8_t *prev2 = (uint8_t*)ctx->frm2;
uint32_t decoded_size;
+ int i, j;
+ int stride = ctx->pitch;
+ uint8_t *dst = (uint8_t *)ctx->frm0 + left + top * stride;
+ uint8_t *prev1 = (uint8_t *)ctx->frm1;
+ uint8_t *prev2 = (uint8_t *)ctx->frm2;
+ int tbl_pos = bytestream2_tell(&ctx->gb);
+ int seq = bytestream2_get_le16(&ctx->gb);
+ int compr = bytestream2_get_byte(&ctx->gb);
+ int new_rot = bytestream2_get_byte(&ctx->gb);
+ int skip = bytestream2_get_byte(&ctx->gb);
- tbl_pos = bytestream2_tell(&ctx->gb);
- seq = bytestream2_get_le16(&ctx->gb);
- compr = bytestream2_get_byte(&ctx->gb);
- new_rot = bytestream2_get_byte(&ctx->gb);
- skip = bytestream2_get_byte(&ctx->gb);
bytestream2_skip(&ctx->gb, 9);
decoded_size = bytestream2_get_le32(&ctx->gb);
bytestream2_skip(&ctx->gb, 8);
if (decoded_size > ctx->height * stride - left - top * stride) {
decoded_size = ctx->height * stride - left - top * stride;
- av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n");
+ av_log(ctx->avctx, AV_LOG_WARNING, "Decoded size is too large.\n");
}
if (skip & 1)
@@ -663,7 +886,7 @@ static int old_codec47(SANMVideoContext *ctx, int top,
memset(prev1, 0, ctx->height * stride);
memset(prev2, 0, ctx->height * stride);
}
- av_dlog(ctx->avctx, "compression %d\n", compr);
+
switch (compr) {
case 0:
if (bytestream2_get_bytes_left(&ctx->gb) < width * height)
@@ -678,8 +901,10 @@ static int old_codec47(SANMVideoContext *ctx, int top,
return AVERROR_INVALIDDATA;
for (j = 0; j < height; j += 2) {
for (i = 0; i < width; i += 2) {
- dst[i] = dst[i + 1] =
- dst[stride + i] = dst[stride + i + 1] = bytestream2_get_byteu(&ctx->gb);
+ dst[i] =
+ dst[i + 1] =
+ dst[stride + i] =
+ dst[stride + i + 1] = bytestream2_get_byteu(&ctx->gb);
}
dst += stride * 2;
}
@@ -687,11 +912,10 @@ static int old_codec47(SANMVideoContext *ctx, int top,
case 2:
if (seq == ctx->prev_seq + 1) {
for (j = 0; j < height; j += 8) {
- for (i = 0; i < width; i += 8) {
+ for (i = 0; i < width; i += 8)
if (process_block(ctx, dst + i, prev1 + i, prev2 + i, stride,
tbl_pos + 8, 8))
return AVERROR_INVALIDDATA;
- }
dst += stride * 8;
prev1 += stride * 8;
prev2 += stride * 8;
@@ -709,8 +933,8 @@ static int old_codec47(SANMVideoContext *ctx, int top,
return AVERROR_INVALIDDATA;
break;
default:
- av_log(ctx->avctx, AV_LOG_ERROR,
- "subcodec 47 compression %d not implemented\n", compr);
+ avpriv_report_missing_feature(ctx->avctx,
+ "Subcodec 47 compression %d", compr);
return AVERROR_PATCHWELCOME;
}
if (seq == ctx->prev_seq + 1)
@@ -724,34 +948,31 @@ static int old_codec47(SANMVideoContext *ctx, int top,
static int process_frame_obj(SANMVideoContext *ctx)
{
- uint16_t codec, top, left, w, h;
-
- codec = bytestream2_get_le16u(&ctx->gb);
- left = bytestream2_get_le16u(&ctx->gb);
- top = bytestream2_get_le16u(&ctx->gb);
- w = bytestream2_get_le16u(&ctx->gb);
- h = bytestream2_get_le16u(&ctx->gb);
+ uint16_t codec = bytestream2_get_le16u(&ctx->gb);
+ uint16_t left = bytestream2_get_le16u(&ctx->gb);
+ uint16_t top = bytestream2_get_le16u(&ctx->gb);
+ uint16_t w = bytestream2_get_le16u(&ctx->gb);
+ uint16_t h = bytestream2_get_le16u(&ctx->gb);
if (!w || !h) {
- av_log(ctx->avctx, AV_LOG_ERROR, "dimensions are invalid\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Dimensions are invalid.\n");
return AVERROR_INVALIDDATA;
}
if (ctx->width < left + w || ctx->height < top + h) {
int ret = ff_set_dimensions(ctx->avctx, FFMAX(left + w, ctx->width),
- FFMAX(top + h, ctx->height));
+ FFMAX(top + h, ctx->height));
if (ret < 0)
return ret;
init_sizes(ctx, FFMAX(left + w, ctx->width),
- FFMAX(top + h, ctx->height));
+ FFMAX(top + h, ctx->height));
if (init_buffers(ctx)) {
- av_log(ctx->avctx, AV_LOG_ERROR, "error resizing buffers\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Error resizing buffers.\n");
return AVERROR(ENOMEM);
}
}
bytestream2_skip(&ctx->gb, 4);
- av_dlog(ctx->avctx, "subcodec %d\n", codec);
switch (codec) {
case 1:
case 3:
@@ -764,7 +985,7 @@ static int process_frame_obj(SANMVideoContext *ctx)
return old_codec47(ctx, top, left, w, h);
break;
default:
- avpriv_request_sample(ctx->avctx, "unknown subcodec %d", codec);
+ avpriv_request_sample(ctx->avctx, "Subcodec %d", codec);
return AVERROR_PATCHWELCOME;
}
}
@@ -775,7 +996,7 @@ static int decode_0(SANMVideoContext *ctx)
int x, y;
if (bytestream2_get_bytes_left(&ctx->gb) < ctx->width * ctx->height * 2) {
- av_log(ctx->avctx, AV_LOG_ERROR, "insufficient data for raw frame\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Insufficient data for raw frame.\n");
return AVERROR_INVALIDDATA;
}
for (y = 0; y < ctx->height; y++) {
@@ -788,7 +1009,7 @@ static int decode_0(SANMVideoContext *ctx)
static int decode_nop(SANMVideoContext *ctx)
{
- avpriv_request_sample(ctx->avctx, "unknown/unsupported compression type");
+ avpriv_request_sample(ctx->avctx, "Unknown/unsupported compression type");
return AVERROR_PATCHWELCOME;
}
@@ -821,15 +1042,16 @@ static void fill_block(uint16_t *pdest, uint16_t color, int block_size, int pitc
*pdest++ = color;
}
-static int draw_glyph(SANMVideoContext *ctx, uint16_t *dst, int index, uint16_t fg_color,
- uint16_t bg_color, int block_size, int pitch)
+static int draw_glyph(SANMVideoContext *ctx, uint16_t *dst, int index,
+ uint16_t fg_color, uint16_t bg_color, int block_size,
+ int pitch)
{
int8_t *pglyph;
uint16_t colors[2] = { fg_color, bg_color };
int x, y;
if (index >= NGLYPHS) {
- av_log(ctx->avctx, AV_LOG_ERROR, "ignoring nonexistent glyph #%u\n", index);
+ av_log(ctx->avctx, AV_LOG_ERROR, "Ignoring nonexistent glyph #%u.\n", index);
return AVERROR_INVALIDDATA;
}
@@ -853,9 +1075,12 @@ static int opcode_0xf7(SANMVideoContext *ctx, int cx, int cy, int block_size, in
return AVERROR_INVALIDDATA;
indices = bytestream2_get_le32u(&ctx->gb);
- dst[0] = ctx->codebook[indices & 0xFF]; indices >>= 8;
- dst[1] = ctx->codebook[indices & 0xFF]; indices >>= 8;
- dst[pitch] = ctx->codebook[indices & 0xFF]; indices >>= 8;
+ dst[0] = ctx->codebook[indices & 0xFF];
+ indices >>= 8;
+ dst[1] = ctx->codebook[indices & 0xFF];
+ indices >>= 8;
+ dst[pitch] = ctx->codebook[indices & 0xFF];
+ indices >>= 8;
dst[pitch + 1] = ctx->codebook[indices & 0xFF];
} else {
uint16_t fgcolor, bgcolor;
@@ -909,10 +1134,10 @@ static int good_mvec(SANMVideoContext *ctx, int cx, int cy, int mx, int my,
int good = start_pos >= 0 && end_pos < (ctx->buf_size >> 1);
- if (!good) {
- av_log(ctx->avctx, AV_LOG_ERROR, "ignoring invalid motion vector (%i, %i)->(%u, %u), block size = %u\n",
+ if (!good)
+ av_log(ctx->avctx, AV_LOG_ERROR,
+ "Ignoring invalid motion vector (%i, %i)->(%u, %u), block size = %u\n",
cx + mx, cy + my, cx, cy, block_size);
- }
return good;
}
@@ -927,7 +1152,6 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size)
opcode = bytestream2_get_byteu(&ctx->gb);
- av_dlog(ctx->avctx, "opcode 0x%0X cx %d cy %d blk %d\n", opcode, cx, cy, blk_size);
switch (opcode) {
default:
mx = motion_vectors[opcode][0];
@@ -989,11 +1213,11 @@ static int codec2subblock(SANMVideoContext *ctx, int cx, int cy, int blk_size)
opcode_0xf8(ctx, cx, cy, blk_size, ctx->pitch);
} else {
blk_size >>= 1;
- if (codec2subblock(ctx, cx , cy , blk_size))
+ if (codec2subblock(ctx, cx, cy, blk_size))
return AVERROR_INVALIDDATA;
- if (codec2subblock(ctx, cx + blk_size, cy , blk_size))
+ if (codec2subblock(ctx, cx + blk_size, cy, blk_size))
return AVERROR_INVALIDDATA;
- if (codec2subblock(ctx, cx , cy + blk_size, blk_size))
+ if (codec2subblock(ctx, cx, cy + blk_size, blk_size))
return AVERROR_INVALIDDATA;
if (codec2subblock(ctx, cx + blk_size, cy + blk_size, blk_size))
return AVERROR_INVALIDDATA;
@@ -1007,12 +1231,10 @@ static int decode_2(SANMVideoContext *ctx)
{
int cx, cy, ret;
- for (cy = 0; cy < ctx->aligned_height; cy += 8) {
- for (cx = 0; cx < ctx->aligned_width; cx += 8) {
+ for (cy = 0; cy < ctx->aligned_height; cy += 8)
+ for (cx = 0; cx < ctx->aligned_width; cx += 8)
if (ret = codec2subblock(ctx, cx, cy, 8))
return ret;
- }
- }
return 0;
}
@@ -1058,7 +1280,7 @@ static int decode_6(SANMVideoContext *ctx)
uint16_t *frm = ctx->frm0;
if (bytestream2_get_bytes_left(&ctx->gb) < npixels) {
- av_log(ctx->avctx, AV_LOG_ERROR, "insufficient data for frame\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "Insufficient data for frame.\n");
return AVERROR_INVALIDDATA;
}
while (npixels--)
@@ -1075,7 +1297,7 @@ static int decode_8(SANMVideoContext *ctx)
av_fast_malloc(&ctx->rle_buf, &ctx->rle_buf_size, npixels);
if (!ctx->rle_buf) {
- av_log(ctx->avctx, AV_LOG_ERROR, "RLE buffer allocation failed\n");
+ av_log(ctx->avctx, AV_LOG_ERROR, "RLE buffer allocation failed.\n");
return AVERROR(ENOMEM);
}
rsrc = ctx->rle_buf;
@@ -1101,7 +1323,7 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr)
int i, ret;
if ((ret = bytestream2_get_bytes_left(&ctx->gb)) < 560) {
- av_log(ctx->avctx, AV_LOG_ERROR, "too short input frame (%d bytes)\n",
+ av_log(ctx->avctx, AV_LOG_ERROR, "Input frame too short (%d bytes).\n",
ret);
return AVERROR_INVALIDDATA;
}
@@ -1111,7 +1333,7 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr)
hdr->height = bytestream2_get_le32u(&ctx->gb);
if (hdr->width != ctx->width || hdr->height != ctx->height) {
- av_log(ctx->avctx, AV_LOG_ERROR, "variable size frames are not implemented\n");
+ avpriv_report_missing_feature(ctx->avctx, "Variable size frames");
return AVERROR_PATCHWELCOME;
}
@@ -1133,7 +1355,6 @@ static int read_frame_header(SANMVideoContext *ctx, SANMFrameHeader *hdr)
bytestream2_skip(&ctx->gb, 8); // skip pad
- av_dlog(ctx->avctx, "subcodec %d\n", hdr->codec);
return 0;
}
@@ -1186,17 +1407,17 @@ static int decode_frame(AVCodecContext *avctx, void *data,
pos = bytestream2_tell(&ctx->gb);
if (bytestream2_get_bytes_left(&ctx->gb) < size) {
- av_log(avctx, AV_LOG_ERROR, "incorrect chunk size %d\n", size);
+ av_log(avctx, AV_LOG_ERROR, "Incorrect chunk size %d.\n", size);
break;
}
switch (sig) {
case MKBETAG('N', 'P', 'A', 'L'):
- if (size != 256 * 3) {
- av_log(avctx, AV_LOG_ERROR, "incorrect palette block size %d\n",
- size);
+ if (size != PALETTE_SIZE * 3) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Incorrect palette block size %d.\n", size);
return AVERROR_INVALIDDATA;
}
- for (i = 0; i < 256; i++)
+ for (i = 0; i < PALETTE_SIZE; i++)
ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->gb);
break;
case MKBETAG('F', 'O', 'B', 'J'):
@@ -1210,7 +1431,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
uint8_t tmp[3];
int j;
- for (i = 0; i < 256; i++) {
+ for (i = 0; i < PALETTE_SIZE; i++) {
for (j = 0; j < 3; j++) {
int t = (ctx->pal[i] >> (16 - j * 8)) & 0xFF;
tmp[j] = av_clip_uint8((t * 129 + ctx->delta_pal[i * 3 + j]) >> 7);
@@ -1218,16 +1439,16 @@ static int decode_frame(AVCodecContext *avctx, void *data,
ctx->pal[i] = 0xFFU << 24 | AV_RB24(tmp);
}
} else {
- if (size < 768 * 2 + 4) {
- av_log(avctx, AV_LOG_ERROR, "incorrect palette change block size %d\n",
+ if (size < PALETTE_DELTA * 2 + 4) {
+ av_log(avctx, AV_LOG_ERROR, "Incorrect palette change block size %d.\n",
size);
return AVERROR_INVALIDDATA;
}
bytestream2_skipu(&ctx->gb, 4);
- for (i = 0; i < 768; i++)
+ for (i = 0; i < PALETTE_DELTA; i++)
ctx->delta_pal[i] = bytestream2_get_le16u(&ctx->gb);
- if (size >= 768 * 5 + 4) {
- for (i = 0; i < 256; i++)
+ if (size >= PALETTE_DELTA * 5 + 4) {
+ for (i = 0; i < PALETTE_SIZE; i++)
ctx->pal[i] = 0xFFU << 24 | bytestream2_get_be24u(&ctx->gb);
} else {
memset(ctx->pal, 0, sizeof(ctx->pal));
@@ -1242,7 +1463,7 @@ static int decode_frame(AVCodecContext *avctx, void *data,
break;
default:
bytestream2_skip(&ctx->gb, size);
- av_log(avctx, AV_LOG_DEBUG, "unknown/unsupported chunk %x\n", sig);
+ av_log(avctx, AV_LOG_DEBUG, "Unknown/unsupported chunk %x.\n", sig);
break;
}
@@ -1273,12 +1494,11 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (header.codec < FF_ARRAY_ELEMS(v1_decoders)) {
if ((ret = v1_decoders[header.codec](ctx))) {
av_log(avctx, AV_LOG_ERROR,
- "subcodec %d: error decoding frame\n", header.codec);
+ "Subcodec %d: error decoding frame.\n", header.codec);
return ret;
}
} else {
- avpriv_request_sample(avctx, "subcodec %d",
- header.codec);
+ avpriv_request_sample(avctx, "Subcodec %d", header.codec);
return AVERROR_PATCHWELCOME;
}
@@ -1288,14 +1508,14 @@ static int decode_frame(AVCodecContext *avctx, void *data,
if (ctx->rotate_code)
rotate_bufs(ctx, ctx->rotate_code);
- *got_frame_ptr = 1;
+ *got_frame_ptr = 1;
return pkt->size;
}
AVCodec ff_sanm_decoder = {
.name = "sanm",
- .long_name = NULL_IF_CONFIG_SMALL("LucasArts SMUSH video"),
+ .long_name = NULL_IF_CONFIG_SMALL("LucasArts SANM/Smush video"),
.type = AVMEDIA_TYPE_VIDEO,
.id = AV_CODEC_ID_SANM,
.priv_data_size = sizeof(SANMVideoContext),