提交 6071e4d8 编写于 作者: M Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  v410dec: Check for sufficient input data. Fixes crash
  fate: Add v210 codec regression tests
  mpegts: adjustable minimum PES payload
  mpegts: properly output large audio packets
  avformat: Add SMJPEG demuxer.
  Indeo 4 decoder

Conflicts:
	doc/general.texi
	libavcodec/v410dec.c
	libavcodec/version.h
	libavformat/mpegtsenc.c
	libavformat/smjpeg.c
	libavformat/version.h
	tests/codec-regression.sh
Merged-by: NMichael Niedermayer <michaelni@gmx.at>
......@@ -147,6 +147,8 @@ easier to use. The changes are:
- Dxtory capture format decoder
- cellauto source
- Simple segmenting muxer
- Indeo 4 decoder
- SMJPEG demuxer
version 0.8:
......
......@@ -318,6 +318,7 @@ library:
@item Smacker @tab @tab X
@tab Multimedia format used by many games.
@item SMJPEG @tab @tab X
@tab Used in certain Loki game ports.
@item Sony OpenMG (OMA) @tab X @tab X
@tab Audio format used in Sony Sonic Stage and Sony Vegas.
@item Sony PlayStation STR @tab @tab X
......@@ -513,6 +514,7 @@ following image formats are supported:
@item Intel H.263 @tab @tab X
@item Intel Indeo 2 @tab @tab X
@item Intel Indeo 3 @tab @tab X
@item Intel Indeo 4 @tab @tab X
@item Intel Indeo 5 @tab @tab X
@item Interplay C93 @tab @tab X
@tab Used in the game Cyberia from Interplay.
......
......@@ -208,6 +208,7 @@ OBJS-$(CONFIG_IFF_ILBM_DECODER) += iff.o
OBJS-$(CONFIG_IMC_DECODER) += imc.o
OBJS-$(CONFIG_INDEO2_DECODER) += indeo2.o
OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o
OBJS-$(CONFIG_INDEO4_DECODER) += indeo4.o ivi_common.o ivi_dsp.o
OBJS-$(CONFIG_INDEO5_DECODER) += indeo5.o ivi_common.o ivi_dsp.o
OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o
OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
......
......@@ -133,6 +133,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (IFF_ILBM, iff_ilbm);
REGISTER_DECODER (INDEO2, indeo2);
REGISTER_DECODER (INDEO3, indeo3);
REGISTER_DECODER (INDEO4, indeo4);
REGISTER_DECODER (INDEO5, indeo5);
REGISTER_DECODER (INTERPLAY_VIDEO, interplay_video);
REGISTER_ENCDEC (JPEG2000, jpeg2000);
......
此差异已折叠。
/*
* Indeo Video Interactive 4 compatible decoder
* Copyright (c) 2009-2010 Maxim Poliakovski
*
* This file is part of Libav.
*
* Libav 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.
*
* Libav 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 Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* @file
* This file contains data needed for the Indeo 4 decoder.
*/
#ifndef AVCODEC_INDEO4DATA_H
#define AVCODEC_INDEO4DATA_H
#include <stdint.h>
#include "dsputil.h"
#include "ivi_common.h"
/**
* standard picture dimensions
*/
static const uint16_t ivi4_common_pic_sizes[14] = {
640, 480, 320, 240, 160, 120, 704, 480, 352, 240, 352, 288, 176, 144
};
/**
* Indeo 4 8x8 scan (zigzag) patterns
*/
static const uint8_t ivi4_alternate_scan_8x8[64] = {
0, 8, 1, 9, 16, 24, 2, 3, 17, 25, 10, 11, 32, 40, 48, 56,
4, 5, 6, 7, 33, 41, 49, 57, 18, 19, 26, 27, 12, 13, 14, 15,
34, 35, 43, 42, 50, 51, 59, 58, 20, 21, 22, 23, 31, 30, 29, 28,
36, 37, 38, 39, 47, 46, 45, 44, 52, 53, 54, 55, 63, 62, 61, 60
};
static const uint8_t ivi4_alternate_scan_4x4[16] = {
0, 1, 4, 5, 8, 12, 2, 3, 9, 13, 6, 7, 10, 11, 14, 15
};
static const uint8_t ivi4_vertical_scan_4x4[16] = {
0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15
};
static const uint8_t ivi4_horizontal_scan_4x4[16] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
static const uint8_t *scan_index_to_tab[15] = {
// for 8x8 transforms
ff_zigzag_direct,
ivi4_alternate_scan_8x8,
ff_ivi_horizontal_scan_8x8,
ff_ivi_vertical_scan_8x8,
ff_zigzag_direct,
// for 4x4 transforms
ff_ivi_direct_scan_4x4,
ivi4_alternate_scan_4x4,
ivi4_vertical_scan_4x4,
ivi4_horizontal_scan_4x4,
ff_ivi_direct_scan_4x4,
// TODO: check if those are needed
ff_ivi_horizontal_scan_8x8,
ff_ivi_horizontal_scan_8x8,
ff_ivi_horizontal_scan_8x8,
ff_ivi_horizontal_scan_8x8,
ff_ivi_horizontal_scan_8x8
};
/**
* Indeo 4 dequant tables
*/
static uint16_t ivi4_quant_8x8_intra[9][64] = {
{
43, 342, 385, 470, 555, 555, 598, 726,
342, 342, 470, 513, 555, 598, 726, 769,
385, 470, 555, 555, 598, 726, 726, 811,
470, 470, 555, 555, 598, 726, 769, 854,
470, 555, 555, 598, 683, 726, 854, 1025,
555, 555, 598, 683, 726, 854, 1025, 1153,
555, 555, 598, 726, 811, 982, 1195, 1451,
555, 598, 726, 811, 982, 1195, 1451, 1793
},
{
86, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
1195, 1195, 2390, 2390, 4865, 4865, 4865, 4865,
2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
2390, 2390, 4865, 4865, 6827, 6827, 6827, 6827,
4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827,
4865, 4865, 6827, 6827, 6827, 6827, 6827, 6827
},
{
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835,
235, 1067, 1195, 1323, 1451, 1579, 1707, 1835
},
{
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414,
1707, 1707, 3414, 3414, 3414, 3414, 3414, 3414
},
{
897, 897, 897, 897, 897, 897, 897, 897,
1067, 1067, 1067, 1067, 1067, 1067, 1067, 1067,
1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
1409, 1409, 1409, 1409, 1409, 1409, 1409, 1409,
1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579,
1750, 1750, 1750, 1750, 1750, 1750, 1750, 1750,
1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921,
2091, 2091, 2091, 2091, 2091, 2091, 2091, 2091
},
{
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414
},
{
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390,
2390, 2390, 2390, 2390, 2390, 2390, 2390, 2390
},
{
22, 171, 214, 257, 257, 299, 299, 342,
171, 171, 257, 257, 299, 299, 342, 385,
214, 257, 257, 299, 299, 342, 342, 385,
257, 257, 257, 299, 299, 342, 385, 427,
257, 257, 299, 299, 342, 385, 427, 513,
257, 299, 299, 342, 385, 427, 513, 598,
299, 299, 299, 385, 385, 470, 598, 726,
299, 299, 385, 385, 470, 598, 726, 897
},
{
86, 598, 1195, 1195, 2390, 2390, 2390, 2390,
598, 598, 1195, 1195, 2390, 2390, 2390, 2390,
1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
1195, 1195, 2390, 2390, 3414, 3414, 3414, 3414,
2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414,
2390, 2390, 3414, 3414, 3414, 3414, 3414, 3414
}
};
static uint16_t ivi4_quant_8x8_inter[9][64] = {
{
427, 427, 470, 427, 427, 427, 470, 470,
427, 427, 470, 427, 427, 427, 470, 470,
470, 470, 470, 470, 470, 470, 470, 470,
427, 427, 470, 470, 427, 427, 470, 470,
427, 427, 470, 427, 427, 427, 470, 470,
427, 427, 470, 427, 427, 427, 470, 470,
470, 470, 470, 470, 470, 470, 470, 470,
470, 470, 470, 470, 470, 470, 470, 470
},
{
1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
1707, 1707, 2433, 2433, 3414, 3414, 3414, 3414,
2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
2433, 2433, 3414, 3414, 4822, 4822, 4822, 4822,
3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414,
3414, 3414, 4822, 4822, 3414, 3414, 3414, 3414
},
{
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281,
1195, 1195, 1281, 1238, 1195, 1195, 1281, 1281
},
{
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433,
2433, 2433, 3414, 3414, 2433, 2433, 2433, 2433
},
{
1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
1238, 1238, 1238, 1238, 1238, 1238, 1238, 1238,
1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
1195, 1195, 1195, 1195, 1195, 1195, 1195, 1195,
1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281,
1281, 1281, 1281, 1281, 1281, 1281, 1281, 1281
},
{
2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
3414, 3414, 3414, 3414, 3414, 3414, 3414, 3414,
2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433,
2433, 2433, 2433, 2433, 2433, 2433, 2433, 2433
},
{
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707,
1707, 1707, 1707, 1707, 1707, 1707, 1707, 1707
},
{
86, 171, 171, 214, 214, 214, 214, 257,
171, 171, 214, 214, 214, 214, 257, 257,
171, 214, 214, 214, 214, 257, 257, 257,
214, 214, 214, 214, 257, 257, 257, 299,
214, 214, 214, 257, 257, 257, 299, 299,
214, 214, 257, 257, 257, 299, 299, 299,
214, 257, 257, 257, 299, 299, 299, 342,
257, 257, 257, 299, 299, 299, 342, 342
},
{
854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
854, 854, 1195, 1195, 1707, 1707, 1707, 1707,
1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
1195, 1195, 1707, 1707, 2390, 2390, 2390, 2390,
1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707,
1707, 1707, 2390, 2390, 1707, 1707, 1707, 1707
}
};
static uint16_t ivi4_quant_4x4_intra[5][16] = {
{
22, 214, 257, 299,
214, 257, 299, 342,
257, 299, 342, 427,
299, 342, 427, 513
},
{
129, 1025, 1451, 1451,
1025, 1025, 1451, 1451,
1451, 1451, 2049, 2049,
1451, 1451, 2049, 2049
},
{
43, 171, 171, 171,
43, 171, 171, 171,
43, 171, 171, 171,
43, 171, 171, 171
},
{
43, 43, 43, 43,
171, 171, 171, 171,
171, 171, 171, 171,
171, 171, 171, 171
},
{
43, 43, 43, 43,
43, 43, 43, 43,
43, 43, 43, 43,
43, 43, 43, 43
}
};
static uint16_t ivi4_quant_4x4_inter[5][16] = {
{
107, 214, 257, 299,
214, 257, 299, 299,
257, 299, 299, 342,
299, 299, 342, 342
},
{
513, 1025, 1238, 1238,
1025, 1025, 1238, 1238,
1238, 1238, 1451, 1451,
1238, 1238, 1451, 1451
},
{
43, 171, 171, 171,
43, 171, 171, 171,
43, 171, 171, 171,
43, 171, 171, 171
},
{
43, 43, 43, 43,
171, 171, 171, 171,
171, 171, 171, 171,
171, 171, 171, 171
},
{
43, 43, 43, 43,
43, 43, 43, 43,
43, 43, 43, 43,
43, 43, 43, 43
}
};
/**
* Table for mapping quant matrix index from the bitstream
* into internal quant table number.
*/
static uint8_t quant_index_to_tab[22] = {
0, 1, 0, 2, 1, 3, 0, 4, 1, 5, 0, 1, 6, 7, 8, // for 8x8 quant matrixes
0, 1, 2, 2, 3, 3, 4 // for 4x4 quant matrixes
};
#endif /* AVCODEC_INDEO4DATA_H */
/*
* DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
*
* Copyright (c) 2009 Maxim Poliakovski
* Copyright (c) 2009-2011 Maxim Poliakovski
*
* This file is part of FFmpeg.
*
......@@ -178,6 +178,153 @@ void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
}
}
void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
const int dst_pitch, const int num_bands)
{
int x, y, indx, b0, b1, b2, b3, p0, p1, p2, p3;
const IDWTELEM *b0_ptr, *b1_ptr, *b2_ptr, *b3_ptr;
int32_t pitch;
/* all bands should have the same pitch */
pitch = plane->bands[0].pitch;
/* get pointers to the wavelet bands */
b0_ptr = plane->bands[0].buf;
b1_ptr = plane->bands[1].buf;
b2_ptr = plane->bands[2].buf;
b3_ptr = plane->bands[3].buf;
for (y = 0; y < plane->height; y += 2) {
for (x = 0, indx = 0; x < plane->width; x += 2, indx++) {
/* load coefficients */
b0 = b0_ptr[indx]; //should be: b0 = (num_bands > 0) ? b0_ptr[indx] : 0;
b1 = b1_ptr[indx]; //should be: b1 = (num_bands > 1) ? b1_ptr[indx] : 0;
b2 = b2_ptr[indx]; //should be: b2 = (num_bands > 2) ? b2_ptr[indx] : 0;
b3 = b3_ptr[indx]; //should be: b3 = (num_bands > 3) ? b3_ptr[indx] : 0;
/* haar wavelet recomposition */
p0 = (b0 + b1 + b2 + b3 + 2) >> 2;
p1 = (b0 + b1 - b2 - b3 + 2) >> 2;
p2 = (b0 - b1 + b2 - b3 + 2) >> 2;
p3 = (b0 - b1 - b2 + b3 + 2) >> 2;
/* bias, convert and output four pixels */
dst[x] = av_clip_uint8(p0 + 128);
dst[x + 1] = av_clip_uint8(p1 + 128);
dst[dst_pitch + x] = av_clip_uint8(p2 + 128);
dst[dst_pitch + x + 1] = av_clip_uint8(p3 + 128);
}// for x
dst += dst_pitch << 1;
b0_ptr += pitch;
b1_ptr += pitch;
b2_ptr += pitch;
b3_ptr += pitch;
}// for y
}
/** butterfly operation for the inverse Haar transform */
#define IVI_HAAR_BFLY(s1, s2, o1, o2, t) \
t = (s1 - s2) >> 1;\
o1 = (s1 + s2) >> 1;\
o2 = t;\
/** inverse 8-point Haar transform */
#define INV_HAAR8(s1, s5, s3, s7, s2, s4, s6, s8,\
d1, d2, d3, d4, d5, d6, d7, d8,\
t0, t1, t2, t3, t4, t5, t6, t7, t8) {\
t1 = s1 << 1; t5 = s5 << 1;\
IVI_HAAR_BFLY(t1, t5, t1, t5, t0); IVI_HAAR_BFLY(t1, s3, t1, t3, t0);\
IVI_HAAR_BFLY(t5, s7, t5, t7, t0); IVI_HAAR_BFLY(t1, s2, t1, t2, t0);\
IVI_HAAR_BFLY(t3, s4, t3, t4, t0); IVI_HAAR_BFLY(t5, s6, t5, t6, t0);\
IVI_HAAR_BFLY(t7, s8, t7, t8, t0);\
d1 = COMPENSATE(t1);\
d2 = COMPENSATE(t2);\
d3 = COMPENSATE(t3);\
d4 = COMPENSATE(t4);\
d5 = COMPENSATE(t5);\
d6 = COMPENSATE(t6);\
d7 = COMPENSATE(t7);\
d8 = COMPENSATE(t8); }
/** inverse 4-point Haar transform */
#define INV_HAAR4(s1, s3, s5, s7) {\
HAAR_BFLY(s1, s5); HAAR_BFLY(s1, s3); HAAR_BFLY(s5, s7);\
s1 = COMPENSATE(s1);\
s3 = COMPENSATE(s3);\
s5 = COMPENSATE(s5);\
s7 = COMPENSATE(s7); }
void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
const uint8_t *flags)
{
int i, shift, sp1, sp2, sp3, sp4;
const int32_t *src;
int32_t *dst;
int tmp[64];
int t0, t1, t2, t3, t4, t5, t6, t7, t8;
/* apply the InvHaar8 to all columns */
#define COMPENSATE(x) (x)
src = in;
dst = tmp;
for (i = 0; i < 8; i++) {
if (flags[i]) {
/* pre-scaling */
shift = !(i & 4);
sp1 = src[ 0] << shift;
sp2 = src[ 8] << shift;
sp3 = src[16] << shift;
sp4 = src[24] << shift;
INV_HAAR8( sp1, sp2, sp3, sp4,
src[32], src[40], src[48], src[56],
dst[ 0], dst[ 8], dst[16], dst[24],
dst[32], dst[40], dst[48], dst[56],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
} else
dst[ 0] = dst[ 8] = dst[16] = dst[24] =
dst[32] = dst[40] = dst[48] = dst[56] = 0;
src++;
dst++;
}
#undef COMPENSATE
/* apply the InvHaar8 to all rows */
#define COMPENSATE(x) (x)
src = tmp;
for (i = 0; i < 8; i++) {
if ( !src[0] && !src[1] && !src[2] && !src[3]
&& !src[4] && !src[5] && !src[6] && !src[7]) {
memset(out, 0, 8 * sizeof(out[0]));
} else {
INV_HAAR8(src[0], src[1], src[2], src[3],
src[4], src[5], src[6], src[7],
out[0], out[1], out[2], out[3],
out[4], out[5], out[6], out[7],
t0, t1, t2, t3, t4, t5, t6, t7, t8);
}
src += 8;
out += pitch;
}
#undef COMPENSATE
}
void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
int blk_size)
{
int x, y;
int16_t dc_coeff;
dc_coeff = (*in + 0) >> 3;
for (y = 0; y < blk_size; out += pitch, y++) {
for (x = 0; x < blk_size; x++)
out[x] = dc_coeff;
}
}
/** butterfly operation for the inverse slant transform */
#define IVI_SLANT_BFLY(s1, s2, o1, o2, t) \
t = s1 - s2;\
......
/*
* DSP functions for Indeo Video Interactive codecs (Indeo4 and Indeo5)
*
* Copyright (c) 2009 Maxim Poliakovski
* Copyright (c) 2009-2011 Maxim Poliakovski
*
* This file is part of FFmpeg.
*
......@@ -43,6 +43,43 @@
void ff_ivi_recompose53(const IVIPlaneDesc *plane, uint8_t *dst,
const int dst_pitch, const int num_bands);
/**
* Haar wavelet recomposition filter for Indeo 4
*
* @param[in] plane pointer to the descriptor of the plane being processed
* @param[out] dst pointer to the destination buffer
* @param[in] dst_pitch pitch of the destination buffer
* @param[in] num_bands number of wavelet bands to be processed
*/
void ff_ivi_recompose_haar(const IVIPlaneDesc *plane, uint8_t *dst,
const int dst_pitch, const int num_bands);
/**
* two-dimensional inverse Haar 8x8 transform for Indeo 4
*
* @param[in] in pointer to the vector of transform coefficients
* @param[out] out pointer to the output buffer (frame)
* @param[in] pitch pitch to move to the next y line
* @param[in] flags pointer to the array of column flags:
* != 0 - non_empty column, 0 - empty one
* (this array must be filled by caller)
*/
void ff_ivi_inverse_haar_8x8(const int32_t *in, int16_t *out, uint32_t pitch,
const uint8_t *flags);
/**
* DC-only two-dimensional inverse Haar transform for Indeo 4.
* Performing the inverse transform in this case is equivalent to
* spreading DC_coeff >> 3 over the whole block.
*
* @param[in] in pointer to the dc coefficient
* @param[out] out pointer to the output buffer (frame)
* @param[in] pitch pitch to move to the next y line
* @param[in] blk_size transform block size
*/
void ff_ivi_dc_haar_2d(const int32_t *in, int16_t *out, uint32_t pitch,
int blk_size);
/**
* two-dimensional inverse slant 8x8 transform
*
......
......@@ -55,7 +55,7 @@ static int v410_decode_frame(AVCodecContext *avctx, void *data,
if (pic->data[0])
avctx->release_buffer(avctx, pic);
if (avpkt->size < 4*avctx->height*avctx->width) {
if (avpkt->size < 4 * avctx->height * avctx->width) {
av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n");
return AVERROR(EINVAL);
}
......
......@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 48
#define LIBAVCODEC_VERSION_MINOR 49
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
......@@ -69,6 +69,7 @@ typedef struct MpegTSWrite {
int tsid;
int64_t first_pcr;
int mux_rate; ///< set to 1 when VBR
int pes_payload_size;
int transport_stream_id;
int original_network_id;
......@@ -79,6 +80,10 @@ typedef struct MpegTSWrite {
int m2ts_mode;
} MpegTSWrite;
/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
#define DEFAULT_PES_HEADER_FREQ 16
#define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
static const AVOption options[] = {
{ "mpegts_transport_stream_id", "Set transport_stream_id field.",
offsetof(MpegTSWrite, transport_stream_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM},
......@@ -94,6 +99,8 @@ static const AVOption options[] = {
offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_INT, {.dbl = -1 },
-1,1, AV_OPT_FLAG_ENCODING_PARAM},
{ "muxrate", NULL, offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT, {1}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
{ "pes_payload_size", "Minimum PES packet payload in bytes",
offsetof(MpegTSWrite, pes_payload_size), AV_OPT_TYPE_INT, {DEFAULT_PES_PAYLOAD_SIZE}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM},
{ NULL },
};
......@@ -193,10 +200,6 @@ static int mpegts_write_section1(MpegTSSection *s, int tid, int id,
#define DEFAULT_PROVIDER_NAME "FFmpeg"
#define DEFAULT_SERVICE_NAME "Service01"
/* a PES packet header is generated every DEFAULT_PES_HEADER_FREQ packets */
#define DEFAULT_PES_HEADER_FREQ 16
#define DEFAULT_PES_PAYLOAD_SIZE ((DEFAULT_PES_HEADER_FREQ - 1) * 184 + 170)
/* we retransmit the SI info at this rate */
#define SDT_RETRANS_TIME 500
#define PAT_RETRANS_TIME 100
......@@ -211,7 +214,7 @@ typedef struct MpegTSWriteStream {
int64_t payload_pts;
int64_t payload_dts;
int payload_flags;
uint8_t payload[DEFAULT_PES_PAYLOAD_SIZE];
uint8_t *payload;
ADTSContext *adts;
} MpegTSWriteStream;
......@@ -483,6 +486,9 @@ static int mpegts_write_header(AVFormatContext *s)
const char *provider_name;
int *pids;
// round up to a whole number of TS packets
ts->pes_payload_size = (ts->pes_payload_size + 14 + 183) / 184 * 184 - 14;
ts->tsid = ts->transport_stream_id;
ts->onid = ts->original_network_id;
/* allocate a single DVB service */
......@@ -519,6 +525,9 @@ static int mpegts_write_header(AVFormatContext *s)
if (!ts_st)
goto fail;
st->priv_data = ts_st;
ts_st->payload = av_mallocz(ts->pes_payload_size);
if (!ts_st->payload)
goto fail;
ts_st->service = service;
/* MPEG pid values < 16 are reserved. Applications which set st->id in
* this range are assigned a calculated pid. */
......@@ -554,10 +563,10 @@ static int mpegts_write_header(AVFormatContext *s)
st->codec->extradata_size > 0) {
ts_st->adts = av_mallocz(sizeof(*ts_st->adts));
if (!ts_st->adts)
return AVERROR(ENOMEM);
goto fail;
if (ff_adts_decode_extradata(s, ts_st->adts, st->codec->extradata,
st->codec->extradata_size) < 0)
return -1;
goto fail;
}
}
......@@ -633,7 +642,13 @@ static int mpegts_write_header(AVFormatContext *s)
fail:
av_free(pids);
for(i = 0;i < s->nb_streams; i++) {
MpegTSWriteStream *ts_st;
st = s->streams[i];
ts_st = st->priv_data;
if (ts_st) {
av_freep(&ts_st->payload);
av_freep(&ts_st->adts);
}
av_freep(&st->priv_data);
}
return -1;
......@@ -959,6 +974,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
int size = pkt->size;
uint8_t *buf= pkt->data;
uint8_t *data= NULL;
MpegTSWrite *ts = s->priv_data;
MpegTSWriteStream *ts_st = st->priv_data;
const uint64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE)*2;
int64_t dts = AV_NOPTS_VALUE, pts = AV_NOPTS_VALUE;
......@@ -1034,14 +1050,14 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
}
}
if (ts_st->payload_size && ts_st->payload_size + size > DEFAULT_PES_PAYLOAD_SIZE) {
if (ts_st->payload_size && ts_st->payload_size + size > ts->pes_payload_size) {
mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_size,
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
ts_st->payload_size = 0;
}
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > DEFAULT_PES_PAYLOAD_SIZE) {
if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > ts->pes_payload_size) {
av_assert0(!ts_st->payload_size);
// for video and subtitle, write a single pes packet
mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY);
......@@ -1080,6 +1096,7 @@ static int mpegts_write_end(AVFormatContext *s)
ts_st->payload_pts, ts_st->payload_dts,
ts_st->payload_flags & AV_PKT_FLAG_KEY);
}
av_freep(&ts_st->payload);
av_freep(&ts_st->adts);
}
avio_flush(s->pb);
......
......@@ -21,17 +21,21 @@
/**
* @file
* This is a demuxer for Loki SDL MJPEG files
* This is a demuxer for Loki SDL Motion JPEG files
*/
#include "avformat.h"
#include "internal.h"
#include "riff.h"
static const AVCodecTag codec_smjpeg_tags[] = {
static const AVCodecTag codec_smjpeg_video_tags[] = {
{ CODEC_ID_MJPEG, MKTAG('J', 'F', 'I', 'F') },
{ CODEC_ID_NONE, 0 },
};
static const AVCodecTag codec_smjpeg_audio_tags[] = {
{ CODEC_ID_ADPCM_IMA_SMJPEG, MKTAG('A', 'P', 'C', 'M') },
{ CODEC_ID_PCM_S16LE, MKTAG('N', 'O', 'N', 'E') },
{ CODEC_ID_MJPEG, MKTAG('J', 'F', 'I', 'F') },
{ CODEC_ID_NONE, 0 },
};
......@@ -57,9 +61,9 @@ static int smjpeg_read_header(AVFormatContext *s, AVFormatParameters *ap)
avio_skip(pb, 8); // magic
version = avio_rb32(pb);
if (version) {
if (version)
av_log_ask_for_sample(s, "unknown version %d\n", version);
}
duration = avio_rb32(pb); // in msec
while (!pb->eof_reached) {
......@@ -97,7 +101,7 @@ static int smjpeg_read_header(AVFormatContext *s, AVFormatParameters *ap)
ast->codec->bits_per_coded_sample = avio_r8(pb);
ast->codec->channels = avio_r8(pb);
ast->codec->codec_tag = avio_rl32(pb);
ast->codec->codec_id = ff_codec_get_id(codec_smjpeg_tags,
ast->codec->codec_id = ff_codec_get_id(codec_smjpeg_audio_tags,
ast->codec->codec_tag);
ast->duration = duration;
sc->audio_stream_index = ast->index;
......@@ -120,7 +124,7 @@ static int smjpeg_read_header(AVFormatContext *s, AVFormatParameters *ap)
vst->codec->width = avio_rb16(pb);
vst->codec->height = avio_rb16(pb);
vst->codec->codec_tag = avio_rl32(pb);
vst->codec->codec_id = ff_codec_get_id(codec_smjpeg_tags,
vst->codec->codec_id = ff_codec_get_id(codec_smjpeg_video_tags,
vst->codec->codec_tag);
vst->duration = duration;
sc->video_stream_index = vst->index;
......
......@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
#define LIBAVFORMAT_VERSION_MINOR 28
#define LIBAVFORMAT_VERSION_MINOR 29
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
......
......@@ -320,7 +320,7 @@ do_video_decoding "" "-pix_fmt yuv420p"
fi
if [ -n "$do_v210" ] ; then
do_video_encoding v210.avi "-an -vcodec v210"
do_video_encoding v210.avi "-an -c:v v210"
do_video_decoding "" "-pix_fmt yuv420p"
fi
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册