Commit b81f8880 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master: (23 commits)
  fix AC3ENC_OPT_MODE_ON/OFF
  h264: fix HRD parameters parsing
  prores: implement multithreading.
  prores: idct sse2/sse4 optimizations.
  swscale: use aligned move for storage into temporary buffer.
  prores: extract idct into its own dspcontext and merge with put_pixels.
  h264: fix invalid shifts in init_cavlc_level_tab()
  intfloat_readwrite: fix signed addition overflows
  mov: do not misreport empty stts
  mov: cosmetics, fix for and if spacing
  id3v2: fix NULL pointer dereference
  mov: read album_artist atom
  mov: fix disc/track numbers and totals
  doc: fix references to obsolete presets directories for avconv/ffmpeg
  flashsv: return more meaningful error value
  flashsv: fix typo in av_log() message
  smacker: validate channels and sample format.
  smacker: check buffer size before reading output size
  smacker: validate number of channels
  smacker: Separate audio flags from sample rates in smacker demuxer.
  ...

Conflicts:
	cmdutils.h
	doc/ffmpeg.texi
	libavcodec/Makefile
	libavcodec/motion_est_template.c
	libavformat/id3v2.c
	libavformat/mov.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents b75d89a4 5f3fb599
...@@ -314,7 +314,7 @@ OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o ...@@ -314,7 +314,7 @@ OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o
OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o
OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o
OBJS-$(CONFIG_PRORES_GPL_DECODER) += proresdec_gpl.o OBJS-$(CONFIG_PRORES_GPL_DECODER) += proresdec_gpl.o
OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o
OBJS-$(CONFIG_PTX_DECODER) += ptx.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o
OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o celp_math.o \ OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o celp_math.o \
celp_filters.o acelp_vectors.o \ celp_filters.o acelp_vectors.o \
......
...@@ -73,8 +73,8 @@ typedef int64_t CoefSumType; ...@@ -73,8 +73,8 @@ typedef int64_t CoefSumType;
#define AC3ENC_OPT_OFF 0 #define AC3ENC_OPT_OFF 0
#define AC3ENC_OPT_ON 1 #define AC3ENC_OPT_ON 1
#define AC3ENC_OPT_NOT_INDICATED 0 #define AC3ENC_OPT_NOT_INDICATED 0
#define AC3ENC_OPT_MODE_ON 1 #define AC3ENC_OPT_MODE_ON 2
#define AC3ENC_OPT_MODE_OFF 2 #define AC3ENC_OPT_MODE_OFF 1
/* specific option values */ /* specific option values */
#define AC3ENC_OPT_LARGE_ROOM 1 #define AC3ENC_OPT_LARGE_ROOM 1
......
...@@ -144,6 +144,41 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_s ...@@ -144,6 +144,41 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_s
} }
} }
void ff_init_scantable_permutation(uint8_t *idct_permutation,
int idct_permutation_type)
{
int i;
switch(idct_permutation_type){
case FF_NO_IDCT_PERM:
for(i=0; i<64; i++)
idct_permutation[i]= i;
break;
case FF_LIBMPEG2_IDCT_PERM:
for(i=0; i<64; i++)
idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
break;
case FF_SIMPLE_IDCT_PERM:
for(i=0; i<64; i++)
idct_permutation[i]= simple_mmx_permutation[i];
break;
case FF_TRANSPOSE_IDCT_PERM:
for(i=0; i<64; i++)
idct_permutation[i]= ((i&7)<<3) | (i>>3);
break;
case FF_PARTTRANS_IDCT_PERM:
for(i=0; i<64; i++)
idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
break;
case FF_SSE2_IDCT_PERM:
for(i=0; i<64; i++)
idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
break;
default:
av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
}
}
static int pix_sum_c(uint8_t * pix, int line_size) static int pix_sum_c(uint8_t * pix, int line_size)
{ {
int s, i, j; int s, i, j;
...@@ -3107,32 +3142,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx) ...@@ -3107,32 +3142,6 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i];
} }
switch(c->idct_permutation_type){ ff_init_scantable_permutation(c->idct_permutation,
case FF_NO_IDCT_PERM: c->idct_permutation_type);
for(i=0; i<64; i++)
c->idct_permutation[i]= i;
break;
case FF_LIBMPEG2_IDCT_PERM:
for(i=0; i<64; i++)
c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
break;
case FF_SIMPLE_IDCT_PERM:
for(i=0; i<64; i++)
c->idct_permutation[i]= simple_mmx_permutation[i];
break;
case FF_TRANSPOSE_IDCT_PERM:
for(i=0; i<64; i++)
c->idct_permutation[i]= ((i&7)<<3) | (i>>3);
break;
case FF_PARTTRANS_IDCT_PERM:
for(i=0; i<64; i++)
c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
break;
case FF_SSE2_IDCT_PERM:
for(i=0; i<64; i++)
c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
break;
default:
av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
}
} }
...@@ -204,6 +204,8 @@ typedef struct ScanTable{ ...@@ -204,6 +204,8 @@ typedef struct ScanTable{
} ScanTable; } ScanTable;
void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable); void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
void ff_init_scantable_permutation(uint8_t *idct_permutation,
int idct_permutation_type);
#define EMULATED_EDGE(depth) \ #define EMULATED_EDGE(depth) \
void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, int linesize,\ void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, int linesize,\
......
...@@ -301,7 +301,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, ...@@ -301,7 +301,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
/* check for changes of image width and image height */ /* check for changes of image width and image height */
if (avctx->width != s->image_width || avctx->height != s->image_height) { if (avctx->width != s->image_width || avctx->height != s->image_height) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"Frame width or height differs from first frames!\n"); "Frame width or height differs from first frame!\n");
av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n",
avctx->height, avctx->width, s->image_height, s->image_width); avctx->height, avctx->width, s->image_height, s->image_width);
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
...@@ -367,7 +367,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, ...@@ -367,7 +367,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data,
if (s->color_depth != 0 && s->color_depth != 2) { if (s->color_depth != 0 && s->color_depth != 2) {
av_log(avctx, AV_LOG_ERROR, av_log(avctx, AV_LOG_ERROR,
"%dx%d invalid color depth %d\n", i, j, s->color_depth); "%dx%d invalid color depth %d\n", i, j, s->color_depth);
return -1; return AVERROR_INVALIDDATA;
} }
if (has_diff) { if (has_diff) {
......
...@@ -75,6 +75,20 @@ static inline int get_ue_golomb(GetBitContext *gb){ ...@@ -75,6 +75,20 @@ static inline int get_ue_golomb(GetBitContext *gb){
} }
} }
/**
* Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
*/
static inline unsigned get_ue_golomb_long(GetBitContext *gb)
{
unsigned buf, log;
buf = show_bits_long(gb, 32);
log = 31 - av_log2(buf);
skip_bits_long(gb, log);
return get_bits_long(gb, log + 1) - 1;
}
/** /**
* read unsigned exp golomb code, constraint to a max of 31. * read unsigned exp golomb code, constraint to a max of 31.
* the return value is undefined if the stored value exceeds 31. * the return value is undefined if the stored value exceeds 31.
......
...@@ -298,17 +298,18 @@ static inline int pred_non_zero_count(H264Context *h, int n){ ...@@ -298,17 +298,18 @@ static inline int pred_non_zero_count(H264Context *h, int n){
} }
static av_cold void init_cavlc_level_tab(void){ static av_cold void init_cavlc_level_tab(void){
int suffix_length, mask; int suffix_length;
unsigned int i; unsigned int i;
for(suffix_length=0; suffix_length<7; suffix_length++){ for(suffix_length=0; suffix_length<7; suffix_length++){
for(i=0; i<(1<<LEVEL_TAB_BITS); i++){ for(i=0; i<(1<<LEVEL_TAB_BITS); i++){
int prefix= LEVEL_TAB_BITS - av_log2(2*i); int prefix= LEVEL_TAB_BITS - av_log2(2*i);
int level_code= (prefix<<suffix_length) + (i>>(LEVEL_TAB_BITS-prefix-1-suffix_length)) - (1<<suffix_length);
mask= -(level_code&1);
level_code= (((2+level_code)>>1) ^ mask) - mask;
if(prefix + 1 + suffix_length <= LEVEL_TAB_BITS){ if(prefix + 1 + suffix_length <= LEVEL_TAB_BITS){
int level_code = (prefix << suffix_length) +
(i >> (av_log2(i) - suffix_length)) - (1 << suffix_length);
int mask = -(level_code&1);
level_code = (((2 + level_code) >> 1) ^ mask) - mask;
cavlc_level_tab[suffix_length][i][0]= level_code; cavlc_level_tab[suffix_length][i][0]= level_code;
cavlc_level_tab[suffix_length][i][1]= prefix + 1 + suffix_length; cavlc_level_tab[suffix_length][i][1]= prefix + 1 + suffix_length;
}else if(prefix + 1 <= LEVEL_TAB_BITS){ }else if(prefix + 1 <= LEVEL_TAB_BITS){
......
...@@ -143,8 +143,8 @@ static inline int decode_hrd_parameters(H264Context *h, SPS *sps){ ...@@ -143,8 +143,8 @@ static inline int decode_hrd_parameters(H264Context *h, SPS *sps){
get_bits(&s->gb, 4); /* bit_rate_scale */ get_bits(&s->gb, 4); /* bit_rate_scale */
get_bits(&s->gb, 4); /* cpb_size_scale */ get_bits(&s->gb, 4); /* cpb_size_scale */
for(i=0; i<cpb_count; i++){ for(i=0; i<cpb_count; i++){
get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */ get_ue_golomb_long(&s->gb); /* bit_rate_value_minus1 */
get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */ get_ue_golomb_long(&s->gb); /* cpb_size_value_minus1 */
get_bits1(&s->gb); /* cbr_flag */ get_bits1(&s->gb); /* cbr_flag */
} }
sps->initial_cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; sps->initial_cpb_removal_delay_length = get_bits(&s->gb, 5) + 1;
...@@ -494,6 +494,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){ ...@@ -494,6 +494,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
unsigned int pps_id= get_ue_golomb(&s->gb); unsigned int pps_id= get_ue_golomb(&s->gb);
PPS *pps; PPS *pps;
const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8); const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8);
int bits_left;
if(pps_id >= MAX_PPS_COUNT) { if(pps_id >= MAX_PPS_COUNT) {
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
...@@ -570,6 +571,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){ ...@@ -570,6 +571,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){
memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4));
memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8));
bits_left = bit_length - get_bits_count(&s->gb);
if(get_bits_count(&s->gb) < bit_length){ if(get_bits_count(&s->gb) < bit_length){
pps->transform_8x8_mode= get_bits1(&s->gb); pps->transform_8x8_mode= get_bits1(&s->gb);
decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8);
......
...@@ -52,7 +52,7 @@ static inline int sad_hpel_motion_search(MpegEncContext * s, ...@@ -52,7 +52,7 @@ static inline int sad_hpel_motion_search(MpegEncContext * s,
int src_index, int ref_index, int src_index, int ref_index,
int size, int h); int size, int h);
static inline int update_map_generation(MotionEstContext *c) static inline unsigned update_map_generation(MotionEstContext *c)
{ {
c->map_generation+= 1<<(ME_MAP_MV_BITS*2); c->map_generation+= 1<<(ME_MAP_MV_BITS*2);
if(c->map_generation==0){ if(c->map_generation==0){
......
...@@ -90,8 +90,8 @@ static int hpel_motion_search(MpegEncContext * s, ...@@ -90,8 +90,8 @@ static int hpel_motion_search(MpegEncContext * s,
+ (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*c->penalty_factor; + (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*c->penalty_factor;
#if 1 #if 1
int key; unsigned key;
int map_generation= c->map_generation; unsigned map_generation= c->map_generation;
#ifndef NDEBUG #ifndef NDEBUG
uint32_t *map= c->map; uint32_t *map= c->map;
#endif #endif
...@@ -210,7 +210,7 @@ static int qpel_motion_search(MpegEncContext * s, ...@@ -210,7 +210,7 @@ static int qpel_motion_search(MpegEncContext * s,
const int mx = *mx_ptr; const int mx = *mx_ptr;
const int my = *my_ptr; const int my = *my_ptr;
const int penalty_factor= c->sub_penalty_factor; const int penalty_factor= c->sub_penalty_factor;
const int map_generation= c->map_generation; const unsigned map_generation = c->map_generation;
const int subpel_quality= c->avctx->me_subpel_quality; const int subpel_quality= c->avctx->me_subpel_quality;
uint32_t *map= c->map; uint32_t *map= c->map;
me_cmp_func cmpf, chroma_cmpf; me_cmp_func cmpf, chroma_cmpf;
...@@ -356,7 +356,7 @@ static int qpel_motion_search(MpegEncContext * s, ...@@ -356,7 +356,7 @@ static int qpel_motion_search(MpegEncContext * s,
#define CHECK_MV(x,y)\ #define CHECK_MV(x,y)\
{\ {\
const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\ const unsigned key = ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\ const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
assert((x) >= xmin);\ assert((x) >= xmin);\
assert((x) <= xmax);\ assert((x) <= xmax);\
...@@ -384,7 +384,7 @@ static int qpel_motion_search(MpegEncContext * s, ...@@ -384,7 +384,7 @@ static int qpel_motion_search(MpegEncContext * s,
#define CHECK_MV_DIR(x,y,new_dir)\ #define CHECK_MV_DIR(x,y,new_dir)\
{\ {\
const int key= ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\ const unsigned key = ((y)<<ME_MAP_MV_BITS) + (x) + map_generation;\
const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\ const int index= (((y)<<ME_MAP_SHIFT) + (x))&(ME_MAP_SIZE-1);\
/*printf("check_mv_dir %d %d %d\n", x, y, new_dir);*/\ /*printf("check_mv_dir %d %d %d\n", x, y, new_dir);*/\
if(map[index]!=key){\ if(map[index]!=key){\
...@@ -422,13 +422,13 @@ static av_always_inline int small_diamond_search(MpegEncContext * s, int *best, ...@@ -422,13 +422,13 @@ static av_always_inline int small_diamond_search(MpegEncContext * s, int *best,
int next_dir=-1; int next_dir=-1;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
cmpf= s->dsp.me_cmp[size]; cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1]; chroma_cmpf= s->dsp.me_cmp[size+1];
{ /* ensure that the best point is in the MAP as h/qpel refinement needs it */ { /* ensure that the best point is in the MAP as h/qpel refinement needs it */
const int key= (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation; const unsigned key = (best[1]<<ME_MAP_MV_BITS) + best[0] + map_generation;
const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1); const int index= ((best[1]<<ME_MAP_SHIFT) + best[0])&(ME_MAP_SIZE-1);
if(map[index]!=key){ //this will be executed only very rarey if(map[index]!=key){ //this will be executed only very rarey
score_map[index]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags); score_map[index]= cmp(s, best[0], best[1], 0, 0, size, h, ref_index, src_index, cmpf, chroma_cmpf, flags);
...@@ -464,7 +464,7 @@ static int funny_diamond_search(MpegEncContext * s, int *best, int dmin, ...@@ -464,7 +464,7 @@ static int funny_diamond_search(MpegEncContext * s, int *best, int dmin,
int dia_size; int dia_size;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
cmpf= s->dsp.me_cmp[size]; cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1]; chroma_cmpf= s->dsp.me_cmp[size+1];
...@@ -505,7 +505,7 @@ static int hex_search(MpegEncContext * s, int *best, int dmin, ...@@ -505,7 +505,7 @@ static int hex_search(MpegEncContext * s, int *best, int dmin,
me_cmp_func cmpf, chroma_cmpf; me_cmp_func cmpf, chroma_cmpf;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
int x,y,d; int x,y,d;
const int dec= dia_size & (dia_size-1); const int dec= dia_size & (dia_size-1);
...@@ -539,7 +539,7 @@ static int l2s_dia_search(MpegEncContext * s, int *best, int dmin, ...@@ -539,7 +539,7 @@ static int l2s_dia_search(MpegEncContext * s, int *best, int dmin,
me_cmp_func cmpf, chroma_cmpf; me_cmp_func cmpf, chroma_cmpf;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
int x,y,i,d; int x,y,i,d;
int dia_size= c->dia_size&0xFF; int dia_size= c->dia_size&0xFF;
const int dec= dia_size & (dia_size-1); const int dec= dia_size & (dia_size-1);
...@@ -577,7 +577,7 @@ static int umh_search(MpegEncContext * s, int *best, int dmin, ...@@ -577,7 +577,7 @@ static int umh_search(MpegEncContext * s, int *best, int dmin,
me_cmp_func cmpf, chroma_cmpf; me_cmp_func cmpf, chroma_cmpf;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
int x,y,x2,y2, i, j, d; int x,y,x2,y2, i, j, d;
const int dia_size= c->dia_size&0xFE; const int dia_size= c->dia_size&0xFE;
static const int hex[16][2]={{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2}, static const int hex[16][2]={{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2},
...@@ -624,7 +624,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin, ...@@ -624,7 +624,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin,
me_cmp_func cmpf, chroma_cmpf; me_cmp_func cmpf, chroma_cmpf;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
int x,y, d; int x,y, d;
const int dia_size= c->dia_size&0xFF; const int dia_size= c->dia_size&0xFF;
...@@ -653,7 +653,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin, ...@@ -653,7 +653,7 @@ static int full_search(MpegEncContext * s, int *best, int dmin,
#define SAB_CHECK_MV(ax,ay)\ #define SAB_CHECK_MV(ax,ay)\
{\ {\
const int key= ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\ const unsigned key = ((ay)<<ME_MAP_MV_BITS) + (ax) + map_generation;\
const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\ const int index= (((ay)<<ME_MAP_SHIFT) + (ax))&(ME_MAP_SIZE-1);\
/*printf("sab check %d %d\n", ax, ay);*/\ /*printf("sab check %d %d\n", ax, ay);*/\
if(map[index]!=key){\ if(map[index]!=key){\
...@@ -692,7 +692,7 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin, ...@@ -692,7 +692,7 @@ static int sab_diamond_search(MpegEncContext * s, int *best, int dmin,
int i, j; int i, j;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
cmpf= s->dsp.me_cmp[size]; cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1]; chroma_cmpf= s->dsp.me_cmp[size+1];
...@@ -777,7 +777,7 @@ static int var_diamond_search(MpegEncContext * s, int *best, int dmin, ...@@ -777,7 +777,7 @@ static int var_diamond_search(MpegEncContext * s, int *best, int dmin,
int dia_size; int dia_size;
LOAD_COMMON LOAD_COMMON
LOAD_COMMON2 LOAD_COMMON2
int map_generation= c->map_generation; unsigned map_generation = c->map_generation;
cmpf= s->dsp.me_cmp[size]; cmpf= s->dsp.me_cmp[size];
chroma_cmpf= s->dsp.me_cmp[size+1]; chroma_cmpf= s->dsp.me_cmp[size+1];
...@@ -869,7 +869,7 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int ...@@ -869,7 +869,7 @@ static av_always_inline int epzs_motion_search_internal(MpegEncContext * s, int
int d; ///< the score (cmp + penalty) of any given mv int d; ///< the score (cmp + penalty) of any given mv
int dmin; /**< the best value of d, i.e. the score int dmin; /**< the best value of d, i.e. the score
corresponding to the mv stored in best[]. */ corresponding to the mv stored in best[]. */
int map_generation; unsigned map_generation;
int penalty_factor; int penalty_factor;
const int ref_mv_stride= s->mb_stride; //pass as arg FIXME const int ref_mv_stride= s->mb_stride; //pass as arg FIXME
const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME
...@@ -997,7 +997,7 @@ static int epzs_motion_search4(MpegEncContext * s, ...@@ -997,7 +997,7 @@ static int epzs_motion_search4(MpegEncContext * s,
MotionEstContext * const c= &s->me; MotionEstContext * const c= &s->me;
int best[2]={0, 0}; int best[2]={0, 0};
int d, dmin; int d, dmin;
int map_generation; unsigned map_generation;
const int penalty_factor= c->penalty_factor; const int penalty_factor= c->penalty_factor;
const int size=1; const int size=1;
const int h=8; const int h=8;
...@@ -1057,7 +1057,7 @@ static int epzs_motion_search2(MpegEncContext * s, ...@@ -1057,7 +1057,7 @@ static int epzs_motion_search2(MpegEncContext * s,
MotionEstContext * const c= &s->me; MotionEstContext * const c= &s->me;
int best[2]={0, 0}; int best[2]={0, 0};
int d, dmin; int d, dmin;
int map_generation; unsigned map_generation;
const int penalty_factor= c->penalty_factor; const int penalty_factor= c->penalty_factor;
const int size=0; //FIXME pass as arg const int size=0; //FIXME pass as arg
const int h=8; const int h=8;
......
...@@ -156,7 +156,7 @@ typedef struct MotionEstContext{ ...@@ -156,7 +156,7 @@ typedef struct MotionEstContext{
int best_bits; int best_bits;
uint32_t *map; ///< map to avoid duplicate evaluations uint32_t *map; ///< map to avoid duplicate evaluations
uint32_t *score_map; ///< map to store the scores uint32_t *score_map; ///< map to store the scores
int map_generation; unsigned map_generation;
int pre_penalty_factor; int pre_penalty_factor;
int penalty_factor; /**< an estimate of the bits required to int penalty_factor; /**< an estimate of the bits required to
code a given mv value, e.g. (1,0) takes code a given mv value, e.g. (1,0) takes
......
This diff is collapsed.
/*
* Apple ProRes compatible decoder
*
* Copyright (c) 2010-2011 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
*/
#include "proresdsp.h"
#include "simple_idct.h"
#define BIAS (1 << (PRORES_BITS_PER_SAMPLE - 1)) ///< bias value for converting signed pixels into unsigned ones
#define CLIP_MIN (1 << (PRORES_BITS_PER_SAMPLE - 8)) ///< minimum value for clipping resulting pixels
#define CLIP_MAX (1 << PRORES_BITS_PER_SAMPLE) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels
#define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX))
/**
* Add bias value, clamp and output pixels of a slice
*/
static void put_pixels(uint16_t *dst, int stride, const DCTELEM *in)
{
int x, y, src_offset, dst_offset;
for (y = 0, dst_offset = 0; y < 8; y++, dst_offset += stride) {
for (x = 0; x < 8; x++) {
src_offset = (y << 3) + x;
dst[dst_offset + x] = CLIP_AND_BIAS(in[src_offset]);
}
}
}
static void prores_idct_put_c(uint16_t *out, int linesize, DCTELEM *block, const int16_t *qmat)
{
ff_prores_idct(block, qmat);
put_pixels(out, linesize >> 1, block);
}
void ff_proresdsp_init(ProresDSPContext *dsp)
{
dsp->idct_put = prores_idct_put_c;
dsp->idct_permutation_type = FF_NO_IDCT_PERM;
if (HAVE_MMX) ff_proresdsp_x86_init(dsp);
ff_init_scantable_permutation(dsp->idct_permutation,
dsp->idct_permutation_type);
}
/*
* Apple ProRes compatible decoder
*
* Copyright (c) 2010-2011 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
*/
#ifndef AVCODEC_PRORESDSP_H
#define AVCODEC_PRORESDSP_H
#include "dsputil.h"
#define PRORES_BITS_PER_SAMPLE 10 ///< output precision of prores decoder
typedef struct {
int idct_permutation_type;
uint8_t idct_permutation[64];
void (* idct_put) (uint16_t *out, int linesize, DCTELEM *block, const int16_t *qmat);
} ProresDSPContext;
void ff_proresdsp_init(ProresDSPContext *dsp);
void ff_proresdsp_x86_init(ProresDSPContext *dsp);
#endif /* AVCODEC_PRORESDSP_H */
...@@ -221,3 +221,20 @@ void ff_simple_idct44_add(uint8_t *dest, int line_size, DCTELEM *block) ...@@ -221,3 +221,20 @@ void ff_simple_idct44_add(uint8_t *dest, int line_size, DCTELEM *block)
idct4col_add(dest + i, line_size, block + i); idct4col_add(dest + i, line_size, block + i);
} }
} }
void ff_prores_idct(DCTELEM *block, const int16_t *qmat)
{
int i;
for (i = 0; i < 64; i++)
block[i] *= qmat[i];
for (i = 0; i < 8; i++)
idctRowCondDC_10(block + i*8);
for (i = 0; i < 64; i++)
block[i] >>= 2;
for (i = 0; i < 8; i++)
idctSparseCol_10(block + i);
}
...@@ -38,6 +38,12 @@ void ff_simple_idct_8(DCTELEM *block); ...@@ -38,6 +38,12 @@ void ff_simple_idct_8(DCTELEM *block);
void ff_simple_idct_put_10(uint8_t *dest, int line_size, DCTELEM *block); void ff_simple_idct_put_10(uint8_t *dest, int line_size, DCTELEM *block);
void ff_simple_idct_add_10(uint8_t *dest, int line_size, DCTELEM *block); void ff_simple_idct_add_10(uint8_t *dest, int line_size, DCTELEM *block);
void ff_simple_idct_10(DCTELEM *block); void ff_simple_idct_10(DCTELEM *block);
/**
* Special version of ff_simple_idct_10() which does dequantization
* and scales by a factor of 2 more between the two IDCTs to account
* for larger scale of input coefficients.
*/
void ff_prores_idct(DCTELEM *block, const int16_t *qmat);
void ff_simple_idct_mmx(int16_t *block); void ff_simple_idct_mmx(int16_t *block);
void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block); void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
......
...@@ -194,14 +194,16 @@ static void decode_parameters(SiprParameters* parms, GetBitContext *pgb, ...@@ -194,14 +194,16 @@ static void decode_parameters(SiprParameters* parms, GetBitContext *pgb,
{ {
int i, j; int i, j;
parms->ma_pred_switch = get_bits(pgb, p->ma_predictor_bits); if (p->ma_predictor_bits)
parms->ma_pred_switch = get_bits(pgb, p->ma_predictor_bits);
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]); parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]);
for (i = 0; i < p->subframe_count; i++) { for (i = 0; i < p->subframe_count; i++) {
parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]); parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]);
parms->gp_index[i] = get_bits(pgb, p->gp_index_bits); if (p->gp_index_bits)
parms->gp_index[i] = get_bits(pgb, p->gp_index_bits);
for (j = 0; j < p->number_of_fc_indexes; j++) for (j = 0; j < p->number_of_fc_indexes; j++)
parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]); parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]);
......
...@@ -560,6 +560,10 @@ static av_cold int decode_end(AVCodecContext *avctx) ...@@ -560,6 +560,10 @@ static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int smka_decode_init(AVCodecContext *avctx) static av_cold int smka_decode_init(AVCodecContext *avctx)
{ {
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n");
return AVERROR(EINVAL);
}
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16; avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16;
return 0; return 0;
...@@ -583,6 +587,11 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, ...@@ -583,6 +587,11 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
int bits, stereo; int bits, stereo;
int pred[2] = {0, 0}; int pred[2] = {0, 0};
if (buf_size <= 4) {
av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
return AVERROR(EINVAL);
}
unp_size = AV_RL32(buf); unp_size = AV_RL32(buf);
init_get_bits(&gb, buf + 4, (buf_size - 4) * 8); init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
...@@ -598,6 +607,14 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, ...@@ -598,6 +607,14 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n"); av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
return -1; return -1;
} }
if (stereo ^ (avctx->channels != 1)) {
av_log(avctx, AV_LOG_ERROR, "channels mismatch\n");
return AVERROR(EINVAL);
}
if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) {
av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n");
return AVERROR(EINVAL);
}
memset(vlc, 0, sizeof(VLC) * 4); memset(vlc, 0, sizeof(VLC) * 4);
memset(h, 0, sizeof(HuffContext) * 4); memset(h, 0, sizeof(HuffContext) * 4);
......
...@@ -34,6 +34,8 @@ MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o ...@@ -34,6 +34,8 @@ MMX-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_mmx.o
YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o YASM-OBJS-$(CONFIG_ENCODERS) += x86/dsputilenc_yasm.o
MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o MMX-OBJS-$(CONFIG_GPL) += x86/idct_mmx.o
MMX-OBJS-$(CONFIG_LPC) += x86/lpc_mmx.o MMX-OBJS-$(CONFIG_LPC) += x86/lpc_mmx.o
YASM-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp.o
MMX-OBJS-$(CONFIG_PRORES_LGPL_DECODER) += x86/proresdsp-init.o
MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp_mmx.o MMX-OBJS-$(CONFIG_DWT) += x86/snowdsp_mmx.o
MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o MMX-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_mmx.o
YASM-OBJS-$(CONFIG_VP3_DECODER) += x86/vp3dsp.o YASM-OBJS-$(CONFIG_VP3_DECODER) += x86/vp3dsp.o
......
...@@ -64,6 +64,8 @@ DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64 ) = {0x0040004000400040ULL, 0x00400 ...@@ -64,6 +64,8 @@ DECLARE_ALIGNED(16, const xmm_reg, ff_pw_64 ) = {0x0040004000400040ULL, 0x00400
DECLARE_ALIGNED(8, const uint64_t, ff_pw_96 ) = 0x0060006000600060ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_96 ) = 0x0060006000600060ULL;
DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL;
DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL;
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_512) = {0x0200020002000200ULL, 0x0200020002000200ULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1019)= {0x03FB03FB03FB03FBULL, 0x03FB03FB03FB03FBULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pb_0 ) = {0x0000000000000000ULL, 0x0000000000000000ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pb_0 ) = {0x0000000000000000ULL, 0x0000000000000000ULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pb_1 ) = {0x0101010101010101ULL, 0x0101010101010101ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pb_1 ) = {0x0101010101010101ULL, 0x0101010101010101ULL};
......
/*
* Apple ProRes compatible decoder
*
* Copyright (c) 2010-2011 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
*/
#include "libavcodec/proresdsp.h"
void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize,
DCTELEM *block);
void ff_prores_idct_put_10_sse4(uint16_t *dst, int linesize,
DCTELEM *block);
void ff_prores_idct_put_10_avx (uint16_t *dst, int linesize,
DCTELEM *block);
void ff_proresdsp_x86_init(ProresDSPContext *dsp)
{
#if ARCH_X86_64
int flags = av_get_cpu_flags();
if (flags & AV_CPU_FLAG_SSE2) {
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
dsp->idct_put = ff_prores_idct_put_10_sse2;
}
if (flags & AV_CPU_FLAG_SSE4) {
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
dsp->idct_put = ff_prores_idct_put_10_sse4;
}
#if HAVE_AVX
if (flags & AV_CPU_FLAG_AVX) {
dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
dsp->idct_put = ff_prores_idct_put_10_avx;
}
#endif
#endif
}
This diff is collapsed.
...@@ -360,7 +360,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t ...@@ -360,7 +360,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
AVIOContext *pbx; AVIOContext *pbx;
unsigned char *buffer = NULL; unsigned char *buffer = NULL;
int buffer_size = 0; int buffer_size = 0;
void (*extra_func)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta**) = NULL; const ID3v2EMFunc *extra_func;
switch (version) { switch (version) {
case 2: case 2:
...@@ -432,7 +432,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t ...@@ -432,7 +432,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag); av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag);
avio_skip(s->pb, tlen); avio_skip(s->pb, tlen);
/* check for text tag or supported special meta tag */ /* check for text tag or supported special meta tag */
} else if (tag[0] == 'T' || (extra_meta && (extra_func = get_extra_meta_func(tag, isv34)->read))) { } else if (tag[0] == 'T' || (extra_meta && (extra_func = get_extra_meta_func(tag, isv34)))) {
if (unsync || tunsync) { if (unsync || tunsync) {
int i, j; int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen); av_fast_malloc(&buffer, &buffer_size, tlen);
...@@ -458,7 +458,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t ...@@ -458,7 +458,7 @@ static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t
read_ttag(s, pbx, tlen, tag); read_ttag(s, pbx, tlen, tag);
else else
/* parse special meta tag */ /* parse special meta tag */
extra_func(s, pbx, tlen, tag, extra_meta); extra_func->read(s, pbx, tlen, tag, extra_meta);
} }
else if (!tag[0]) { else if (!tag[0]) {
if (tag[1]) if (tag[1])
...@@ -521,11 +521,11 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic) ...@@ -521,11 +521,11 @@ void ff_id3v2_read(AVFormatContext *s, const char *magic)
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta) void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
{ {
ID3v2ExtraMeta *current = *extra_meta, *next; ID3v2ExtraMeta *current = *extra_meta, *next;
void (*free_func)(void *); const ID3v2EMFunc *extra_func;
while (current) { while (current) {
if ((free_func = get_extra_meta_func(current->tag, 1)->free)) if ((extra_func = get_extra_meta_func(current->tag, 1)))
free_func(current->data); extra_func->free(current->data);
next = current->next; next = current->next;
av_freep(&current); av_freep(&current);
current = next; current = next;
......
This diff is collapsed.
...@@ -31,11 +31,11 @@ ...@@ -31,11 +31,11 @@
#define SMACKER_FLAG_RING_FRAME 0x01 #define SMACKER_FLAG_RING_FRAME 0x01
enum SAudFlags { enum SAudFlags {
SMK_AUD_PACKED = 0x80000000, SMK_AUD_PACKED = 0x80,
SMK_AUD_16BITS = 0x20000000, SMK_AUD_16BITS = 0x20,
SMK_AUD_STEREO = 0x10000000, SMK_AUD_STEREO = 0x10,
SMK_AUD_BINKAUD = 0x08000000, SMK_AUD_BINKAUD = 0x08,
SMK_AUD_USEDCT = 0x04000000 SMK_AUD_USEDCT = 0x04
}; };
typedef struct SmackerContext { typedef struct SmackerContext {
...@@ -48,6 +48,7 @@ typedef struct SmackerContext { ...@@ -48,6 +48,7 @@ typedef struct SmackerContext {
uint32_t audio[7]; uint32_t audio[7];
uint32_t treesize; uint32_t treesize;
uint32_t mmap_size, mclr_size, full_size, type_size; uint32_t mmap_size, mclr_size, full_size, type_size;
uint8_t aflags[7];
uint32_t rates[7]; uint32_t rates[7];
uint32_t pad; uint32_t pad;
/* frame info */ /* frame info */
...@@ -129,8 +130,10 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -129,8 +130,10 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
smk->mclr_size = avio_rl32(pb); smk->mclr_size = avio_rl32(pb);
smk->full_size = avio_rl32(pb); smk->full_size = avio_rl32(pb);
smk->type_size = avio_rl32(pb); smk->type_size = avio_rl32(pb);
for(i = 0; i < 7; i++) for(i = 0; i < 7; i++) {
smk->rates[i] = avio_rl32(pb); smk->rates[i] = avio_rl24(pb);
smk->aflags[i] = avio_r8(pb);
}
smk->pad = avio_rl32(pb); smk->pad = avio_rl32(pb);
/* setup data */ /* setup data */
if(smk->frames > 0xFFFFFF) { if(smk->frames > 0xFFFFFF) {
...@@ -173,23 +176,23 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) ...@@ -173,23 +176,23 @@ static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* handle possible audio streams */ /* handle possible audio streams */
for(i = 0; i < 7; i++) { for(i = 0; i < 7; i++) {
smk->indexes[i] = -1; smk->indexes[i] = -1;
if(smk->rates[i] & 0xFFFFFF){ if (smk->rates[i]) {
ast[i] = av_new_stream(s, 0); ast[i] = av_new_stream(s, 0);
smk->indexes[i] = ast[i]->index; smk->indexes[i] = ast[i]->index;
ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO;
if (smk->rates[i] & SMK_AUD_BINKAUD) { if (smk->aflags[i] & SMK_AUD_BINKAUD) {
ast[i]->codec->codec_id = CODEC_ID_BINKAUDIO_RDFT; ast[i]->codec->codec_id = CODEC_ID_BINKAUDIO_RDFT;
} else if (smk->rates[i] & SMK_AUD_USEDCT) { } else if (smk->aflags[i] & SMK_AUD_USEDCT) {
ast[i]->codec->codec_id = CODEC_ID_BINKAUDIO_DCT; ast[i]->codec->codec_id = CODEC_ID_BINKAUDIO_DCT;
} else if (smk->rates[i] & SMK_AUD_PACKED){ } else if (smk->aflags[i] & SMK_AUD_PACKED){
ast[i]->codec->codec_id = CODEC_ID_SMACKAUDIO; ast[i]->codec->codec_id = CODEC_ID_SMACKAUDIO;
ast[i]->codec->codec_tag = MKTAG('S', 'M', 'K', 'A'); ast[i]->codec->codec_tag = MKTAG('S', 'M', 'K', 'A');
} else { } else {
ast[i]->codec->codec_id = CODEC_ID_PCM_U8; ast[i]->codec->codec_id = CODEC_ID_PCM_U8;
} }
ast[i]->codec->channels = (smk->rates[i] & SMK_AUD_STEREO) ? 2 : 1; ast[i]->codec->channels = (smk->aflags[i] & SMK_AUD_STEREO) ? 2 : 1;
ast[i]->codec->sample_rate = smk->rates[i] & 0xFFFFFF; ast[i]->codec->sample_rate = smk->rates[i];
ast[i]->codec->bits_per_coded_sample = (smk->rates[i] & SMK_AUD_16BITS) ? 16 : 8; ast[i]->codec->bits_per_coded_sample = (smk->aflags[i] & SMK_AUD_16BITS) ? 16 : 8;
if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8) if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8)
ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE;
av_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate av_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate
......
...@@ -30,13 +30,13 @@ ...@@ -30,13 +30,13 @@
#include "intfloat_readwrite.h" #include "intfloat_readwrite.h"
double av_int2dbl(int64_t v){ double av_int2dbl(int64_t v){
if(v+v > 0xFFEULL<<52) if((uint64_t)v+v > 0xFFEULL<<52)
return NAN; return NAN;
return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075); return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075);
} }
float av_int2flt(int32_t v){ float av_int2flt(int32_t v){
if(v+v > 0xFF000000U) if((uint32_t)v+v > 0xFF000000U)
return NAN; return NAN;
return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150); return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
} }
......
...@@ -369,7 +369,7 @@ cglobal hscale%1to%2_%4_%5, %6, 7, %7 ...@@ -369,7 +369,7 @@ cglobal hscale%1to%2_%4_%5, %6, 7, %7
cvtps2dq m0, m0 cvtps2dq m0, m0
%endif ; mmx/sse2/ssse3/sse4 %endif ; mmx/sse2/ssse3/sse4
%ifnidn %3, X %ifnidn %3, X
movu [r1+r2*(4>>r2shr)], m0 mova [r1+r2*(4>>r2shr)], m0
%else ; %3 == X %else ; %3 == X
movq [r1+r2*4], m0 movq [r1+r2*4], m0
%endif ; %3 ==/!= X %endif ; %3 ==/!= X
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment