* qatar/master: vc1: use an enum for Frame Coding Mode doc: cleanup filter section indeo3: error out if no motion vector is set. x86inc: Flag shufps as an floating-point instruction for the AVX emulation code. mpegaudio: do not use init_static_data() for initializing tables. musepack: fix signed shift overflow in mpc_read_packet() mov: Make format string match variable type. wmavoice: Make format string match variable type. vc1: select interlaced scan table by FCM element Generalize RIFF INFO tag support; support reading INFO tag in wav pthread: track thread existence in a separate variable. Conflicts: doc/filters.texi libavcodec/pthread.c libavformat/avi.c libavformat/riff.c libavformat/riff.h libavformat/wav.c Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n0.9
@@ -1401,8 +1401,7 @@ gradfun=1.2 | |||
Flip the input video horizontally. | |||
For example to horizontally flip the video in input with | |||
@file{ffmpeg}: | |||
For example to horizontally flip the input video with @command{ffmpeg}: | |||
@example | |||
ffmpeg -i in.avi -vf "hflip" out.avi | |||
@end example | |||
@@ -68,7 +68,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, | |||
pp->bPicStructure |= 0x01; | |||
if (s->picture_structure & PICT_BOTTOM_FIELD) | |||
pp->bPicStructure |= 0x02; | |||
pp->bSecondField = v->interlace && v->fcm != 0x03 && !s->first_field; | |||
pp->bSecondField = v->interlace && v->fcm != ILACE_FIELD && !s->first_field; | |||
pp->bPicIntra = s->pict_type == AV_PICTURE_TYPE_I; | |||
pp->bPicBackwardPrediction = s->pict_type == AV_PICTURE_TYPE_B; | |||
pp->bBidirectionalAveragingMode = (1 << 7) | | |||
@@ -100,7 +100,7 @@ static void fill_picture_parameters(AVCodecContext *avctx, | |||
(s->resync_marker << 4) | | |||
(v->rangered << 3) | | |||
(s->max_b_frames ); | |||
pp->bPicExtrapolation = (!v->interlace || v->fcm == 0x00) ? 1 : 2; | |||
pp->bPicExtrapolation = (!v->interlace || v->fcm == PROGRESSIVE) ? 1 : 2; | |||
pp->bPicDeblocked = ((v->profile != PROFILE_ADVANCED && v->rangeredfrm) << 5) | | |||
(s->loop_filter << 1); | |||
pp->bPicDeblockConfined = (v->postprocflag << 7) | | |||
@@ -759,6 +759,8 @@ static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, | |||
av_log(avctx, AV_LOG_ERROR, "SkipCell procedure not implemented yet!\n"); | |||
CHECK_CELL | |||
if(!curr_cell.mv_ptr) | |||
return AVERROR_INVALIDDATA; | |||
copy_cell(ctx, plane, &curr_cell); | |||
return 0; | |||
} | |||
@@ -269,7 +269,7 @@ static inline int l3_unscale(int value, int exponent) | |||
return m; | |||
} | |||
static void decode_init_static(AVCodec *codec) | |||
static av_cold void decode_init_static(void) | |||
{ | |||
int i, j, k; | |||
int offset; | |||
@@ -462,8 +462,14 @@ static void decode_init_static(AVCodec *codec) | |||
static av_cold int decode_init(AVCodecContext * avctx) | |||
{ | |||
static int initialized_tables = 0; | |||
MPADecodeContext *s = avctx->priv_data; | |||
if (!initialized_tables) { | |||
decode_init_static(); | |||
initialized_tables = 1; | |||
} | |||
s->avctx = avctx; | |||
ff_mpadsp_init(&s->mpadsp); | |||
@@ -1996,7 +2002,6 @@ AVCodec ff_mp1_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP1, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame, | |||
#if FF_API_PARSE_FRAME | |||
@@ -2012,7 +2017,6 @@ AVCodec ff_mp2_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP2, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame, | |||
#if FF_API_PARSE_FRAME | |||
@@ -2028,7 +2032,6 @@ AVCodec ff_mp3_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP3, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame, | |||
#if FF_API_PARSE_FRAME | |||
@@ -2044,7 +2047,6 @@ AVCodec ff_mp3adu_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP3ADU, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame_adu, | |||
#if FF_API_PARSE_FRAME | |||
@@ -2060,7 +2062,6 @@ AVCodec ff_mp3on4_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP3ON4, | |||
.priv_data_size = sizeof(MP3On4DecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init_mp3on4, | |||
.close = decode_close_mp3on4, | |||
.decode = decode_frame_mp3on4, | |||
@@ -28,7 +28,6 @@ AVCodec ff_mp1float_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP1, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame, | |||
#if FF_API_PARSE_FRAME | |||
@@ -44,7 +43,6 @@ AVCodec ff_mp2float_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP2, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame, | |||
#if FF_API_PARSE_FRAME | |||
@@ -60,7 +58,6 @@ AVCodec ff_mp3float_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP3, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame, | |||
#if FF_API_PARSE_FRAME | |||
@@ -76,7 +73,6 @@ AVCodec ff_mp3adufloat_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP3ADU, | |||
.priv_data_size = sizeof(MPADecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init, | |||
.decode = decode_frame_adu, | |||
#if FF_API_PARSE_FRAME | |||
@@ -92,7 +88,6 @@ AVCodec ff_mp3on4float_decoder = { | |||
.type = AVMEDIA_TYPE_AUDIO, | |||
.id = CODEC_ID_MP3ON4, | |||
.priv_data_size = sizeof(MP3On4DecodeContext), | |||
.init_static_data = decode_init_static, | |||
.init = decode_init_mp3on4, | |||
.close = decode_close_mp3on4, | |||
.decode = decode_frame_mp3on4, | |||
@@ -72,7 +72,7 @@ typedef struct PerThreadContext { | |||
struct FrameThreadContext *parent; | |||
pthread_t thread; | |||
int thread_created; | |||
int thread_init; | |||
pthread_cond_t input_cond; ///< Used to wait for a new packet from the main thread. | |||
pthread_cond_t progress_cond; ///< Used by child threads to wait for progress to change. | |||
pthread_cond_t output_cond; ///< Used by the main thread to wait for frames to finish. | |||
@@ -659,9 +659,9 @@ static void frame_thread_free(AVCodecContext *avctx, int thread_count) | |||
pthread_cond_signal(&p->input_cond); | |||
pthread_mutex_unlock(&p->mutex); | |||
if (p->thread_created) | |||
if (p->thread_init) | |||
pthread_join(p->thread, NULL); | |||
p->thread_created=0; | |||
p->thread_init=0; | |||
if (codec->close) | |||
codec->close(p->avctx); | |||
@@ -765,8 +765,8 @@ static int frame_thread_init(AVCodecContext *avctx) | |||
if (err) goto error; | |||
p->thread_created= !pthread_create(&p->thread, NULL, frame_worker_thread, p); | |||
if(!p->thread_created) | |||
p->thread_init= !pthread_create(&p->thread, NULL, frame_worker_thread, p); | |||
if(!p->thread_init) | |||
goto error; | |||
} | |||
@@ -841,14 +841,14 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
if (v->interlace) { | |||
v->fcm = decode012(gb); | |||
if (v->fcm) { | |||
if (v->fcm == 2) | |||
if (v->fcm == ILACE_FIELD) | |||
v->field_mode = 1; | |||
if (!v->warn_interlaced++) | |||
av_log(v->s.avctx, AV_LOG_ERROR, | |||
"Interlaced frames/fields support is incomplete\n"); | |||
} | |||
} else { | |||
v->fcm = 0; | |||
v->fcm = PROGRESSIVE; | |||
} | |||
if (v->field_mode) { | |||
@@ -962,7 +962,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
switch (v->s.pict_type) { | |||
case AV_PICTURE_TYPE_I: | |||
case AV_PICTURE_TYPE_BI: | |||
if (v->fcm == 1) { //interlace frame picture | |||
if (v->fcm == ILACE_FRAME) { //interlace frame picture | |||
status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v); | |||
if (status < 0) | |||
return -1; | |||
@@ -1003,7 +1003,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
v->dmvrange = get_unary(gb, 0, 3); | |||
else | |||
v->dmvrange = 0; | |||
if (v->fcm == 1) { // interlaced frame picture | |||
if (v->fcm == ILACE_FRAME) { // interlaced frame picture | |||
v->fourmvswitch = get_bits1(gb); | |||
v->intcomp = get_bits1(gb); | |||
if (v->intcomp) { | |||
@@ -1043,7 +1043,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
v->tt_index = 1; | |||
else | |||
v->tt_index = 2; | |||
if (v->fcm != 1) { | |||
if (v->fcm != ILACE_FRAME) { | |||
int mvmode; | |||
mvmode = get_unary(gb, 1, 4); | |||
lowquant = (v->pq > 12) ? 0 : 1; | |||
@@ -1078,7 +1078,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
|| (v->mv_mode == MV_PMODE_INTENSITY_COMP | |||
&& v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); | |||
} | |||
if (v->fcm == 0) { // progressive | |||
if (v->fcm == PROGRESSIVE) { // progressive | |||
if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && | |||
v->mv_mode2 == MV_PMODE_MIXED_MV) | |||
|| v->mv_mode == MV_PMODE_MIXED_MV) { | |||
@@ -1100,7 +1100,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
/* Hopefully this is correct for P frames */ | |||
v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables | |||
v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; | |||
} else if (v->fcm == 1) { // frame interlaced | |||
} else if (v->fcm == ILACE_FRAME) { // frame interlaced | |||
v->qs_last = v->s.quarter_sample; | |||
v->s.quarter_sample = 1; | |||
v->s.mspel = 1; | |||
@@ -1140,7 +1140,7 @@ int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) | |||
break; | |||
case AV_PICTURE_TYPE_B: | |||
// TODO: implement interlaced frame B picture decoding | |||
if (v->fcm == 1) | |||
if (v->fcm == ILACE_FRAME) | |||
return -1; | |||
if (v->extended_mv) | |||
v->mvrange = get_unary(gb, 0, 3); | |||
@@ -161,6 +161,16 @@ enum COTypes { | |||
}; | |||
//@} | |||
/** | |||
* FCM Frame Coding Mode | |||
* @note some content might be marked interlaced | |||
* but have fcm set to 0 as well (e.g. HD-DVD) | |||
*/ | |||
enum FrameCodingMode { | |||
PROGRESSIVE = 0, ///< in the bitstream is reported as 00b | |||
ILACE_FRAME, ///< in the bitstream is reported as 10b | |||
ILACE_FIELD ///< in the bitstream is reported as 11b | |||
}; | |||
/** The VC1 Context | |||
* @todo Change size wherever another size is more efficient | |||
@@ -296,7 +306,7 @@ typedef struct VC1Context{ | |||
/** Frame decoding info for Advanced profile */ | |||
//@{ | |||
uint8_t fcm; ///< 0->Progressive, 2->Frame-Interlace, 3->Field-Interlace | |||
enum FrameCodingMode fcm; | |||
uint8_t numpanscanwin; | |||
uint8_t tfcntr; | |||
uint8_t rptfrm, tff, rff; | |||
@@ -501,7 +501,8 @@ static void vc1_mc_1mv(VC1Context *v, int dir) | |||
uvmy = uvmy - 2 + 4 * v->cur_field_type; | |||
} | |||
if (v->fastuvmc && (v->fcm != 1)) { // fastuvmc shall be ignored for interlaced frame picture | |||
// fastuvmc shall be ignored for interlaced frame picture | |||
if (v->fastuvmc && (v->fcm != ILACE_FRAME)) { | |||
uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1)); | |||
uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1)); | |||
} | |||
@@ -685,7 +686,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) | |||
uint8_t *srcY; | |||
int dxy, mx, my, src_x, src_y; | |||
int off; | |||
int fieldmv = (v->fcm == 1) ? v->blk_mv_type[s->block_index[n]] : 0; | |||
int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0; | |||
int v_edge_pos = s->v_edge_pos >> v->field_mode; | |||
if (!v->field_mode && !v->s.last_picture.f.data[0]) | |||
@@ -744,7 +745,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) | |||
v->mv_f[1][s->block_index[k] + v->blocks_off] = f; | |||
} | |||
if (v->fcm == 1) { // not sure if needed for other types of picture | |||
if (v->fcm == ILACE_FRAME) { // not sure if needed for other types of picture | |||
int qx, qy; | |||
int width = s->avctx->coded_width; | |||
int height = s->avctx->coded_height >> 1; | |||
@@ -761,7 +762,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) | |||
my -= 8 * (qy - height - 1); | |||
} | |||
if ((v->fcm == 1) && fieldmv) | |||
if ((v->fcm == ILACE_FRAME) && fieldmv) | |||
off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8; | |||
else | |||
off = s->linesize * 4 * (n & 2) + (n & 1) * 8; | |||
@@ -779,7 +780,7 @@ static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) | |||
src_y = av_clip(src_y, -16, s->mb_height * 16); | |||
} else { | |||
src_x = av_clip(src_x, -17, s->avctx->coded_width); | |||
if (v->fcm == 1) { | |||
if (v->fcm == ILACE_FRAME) { | |||
if (src_y & 1) | |||
src_y = av_clip(src_y, -17, s->avctx->coded_height + 1); | |||
else | |||
@@ -2917,7 +2918,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, | |||
int k; | |||
if (v->s.ac_pred) { | |||
if (!use_pred && v->fcm == 1) { | |||
if (!use_pred && v->fcm == ILACE_FRAME) { | |||
zz_table = v->zzi_8x8; | |||
} else { | |||
if (!dc_pred_dir) // top | |||
@@ -2926,7 +2927,7 @@ static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, | |||
zz_table = v->zz_8x8[3]; | |||
} | |||
} else { | |||
if (v->fcm != 1) | |||
if (v->fcm != ILACE_FRAME) | |||
zz_table = v->zz_8x8[1]; | |||
else | |||
zz_table = v->zzi_8x8; | |||
@@ -3136,10 +3137,10 @@ static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, | |||
i += skip; | |||
if (i > 63) | |||
break; | |||
if (v->fcm == 0) | |||
if (v->fcm == PROGRESSIVE) | |||
block[v->zz_8x8[0][i++]] = value; | |||
else { | |||
if (use_pred && (v->fcm == 1)) { | |||
if (use_pred && (v->fcm == ILACE_FRAME)) { | |||
if (!dc_pred_dir) // top | |||
block[v->zz_8x8[2][i++]] = value; | |||
else // left | |||
@@ -4739,12 +4740,12 @@ static void vc1_decode_p_blocks(VC1Context *v) | |||
for (; s->mb_x < s->mb_width; s->mb_x++) { | |||
ff_update_block_index(s); | |||
if (v->fcm == 2) | |||
if (v->fcm == ILACE_FIELD) | |||
vc1_decode_p_mb_intfi(v); | |||
else if (v->fcm == 1) | |||
else if (v->fcm == ILACE_FRAME) | |||
vc1_decode_p_mb_intfr(v); | |||
else vc1_decode_p_mb(v); | |||
if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == 0) | |||
if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == PROGRESSIVE) | |||
vc1_apply_p_loop_filter(v); | |||
if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { | |||
// TODO: may need modification to handle slice coding | |||
@@ -4811,7 +4812,7 @@ static void vc1_decode_b_blocks(VC1Context *v) | |||
for (; s->mb_x < s->mb_width; s->mb_x++) { | |||
ff_update_block_index(s); | |||
if (v->fcm == 2) | |||
if (v->fcm == ILACE_FIELD) | |||
vc1_decode_b_mb_intfi(v); | |||
else | |||
vc1_decode_b_mb(v); | |||
@@ -1795,7 +1795,7 @@ static int synth_superframe(AVCodecContext *ctx, | |||
out_size = n_samples * av_get_bytes_per_sample(ctx->sample_fmt); | |||
if (*data_size < out_size) { | |||
av_log(ctx, AV_LOG_ERROR, | |||
"Output buffer too small (%d given - %zu needed)\n", | |||
"Output buffer too small (%d given - %d needed)\n", | |||
*data_size, out_size); | |||
return -1; | |||
} | |||
@@ -43,8 +43,8 @@ OBJS-$(CONFIG_ASS_DEMUXER) += assdec.o | |||
OBJS-$(CONFIG_ASS_MUXER) += assenc.o | |||
OBJS-$(CONFIG_AU_DEMUXER) += au.o pcm.o | |||
OBJS-$(CONFIG_AU_MUXER) += au.o | |||
OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o riff.o avi.o | |||
OBJS-$(CONFIG_AVI_MUXER) += avienc.o riff.o avi.o | |||
OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o riff.o | |||
OBJS-$(CONFIG_AVI_MUXER) += avienc.o riff.o | |||
OBJS-$(CONFIG_AVISYNTH) += avisynth.o | |||
OBJS-$(CONFIG_AVM2_MUXER) += swfenc.o | |||
OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o | |||
@@ -1,45 +0,0 @@ | |||
/* | |||
* AVI common data | |||
* Copyright (c) 2010 Anton Khirnov | |||
* | |||
* This file is part of FFmpeg. | |||
* | |||
* FFmpeg 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. | |||
* | |||
* FFmpeg 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 FFmpeg; if not, write to the Free Software | |||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |||
*/ | |||
#include "avi.h" | |||
const AVMetadataConv ff_avi_metadata_conv[] = { | |||
{ "IART", "artist" }, | |||
{ "ICMT", "comment" }, | |||
{ "ICOP", "copyright" }, | |||
{ "ICRD", "date" }, | |||
{ "IGNR", "genre" }, | |||
{ "ILNG", "language" }, | |||
{ "INAM", "title" }, | |||
{ "IPRD", "album" }, | |||
{ "IPRT", "track" }, | |||
{ "ISFT", "encoder" }, | |||
{ "ITCH", "encoded_by"}, | |||
{ "strn", "title" }, | |||
{ 0 }, | |||
}; | |||
const char ff_avi_tags[][5] = { | |||
"IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI", | |||
"IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD", | |||
"IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH", | |||
{0} | |||
}; |
@@ -21,8 +21,6 @@ | |||
#ifndef AVFORMAT_AVI_H | |||
#define AVFORMAT_AVI_H | |||
#include "metadata.h" | |||
#define AVIF_HASINDEX 0x00000010 // Index at end of file? | |||
#define AVIF_MUSTUSEINDEX 0x00000020 | |||
#define AVIF_ISINTERLEAVED 0x00000100 | |||
@@ -37,11 +35,4 @@ | |||
/* index flags */ | |||
#define AVIIF_INDEX 0x10 | |||
extern const AVMetadataConv ff_avi_metadata_conv[]; | |||
/** | |||
* A list of AVI info tags. | |||
*/ | |||
extern const char ff_avi_tags[][5]; | |||
#endif /* AVFORMAT_AVI_H */ |
@@ -99,6 +99,11 @@ static const char avi_headers[][8] = { | |||
{ 0 } | |||
}; | |||
static const AVMetadataConv avi_metadata_conv[] = { | |||
{ "strn", "title" }, | |||
{ 0 }, | |||
}; | |||
static int avi_load_index(AVFormatContext *s); | |||
static int guess_ni_flag(AVFormatContext *s); | |||
@@ -287,15 +292,6 @@ static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t | |||
AV_DICT_DONT_STRDUP_VAL); | |||
} | |||
static void avi_read_info(AVFormatContext *s, uint64_t end) | |||
{ | |||
while (avio_tell(s->pb) < end) { | |||
uint32_t tag = avio_rl32(s->pb); | |||
uint32_t size = avio_rl32(s->pb); | |||
avi_read_tag(s, NULL, tag, size); | |||
} | |||
} | |||
static const char months[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", | |||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; | |||
@@ -408,7 +404,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
goto end_of_header; | |||
} | |||
else if (tag1 == MKTAG('I', 'N', 'F', 'O')) | |||
avi_read_info(s, list_end); | |||
ff_read_riff_info(s, size - 4); | |||
else if (tag1 == MKTAG('n', 'c', 'd', 't')) | |||
avi_read_nikon(s, list_end); | |||
@@ -778,7 +774,8 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) | |||
clean_index(s); | |||
} | |||
ff_metadata_conv_ctx(s, NULL, ff_avi_metadata_conv); | |||
ff_metadata_conv_ctx(s, NULL, avi_metadata_conv); | |||
ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); | |||
return 0; | |||
} | |||
@@ -378,9 +378,9 @@ static int avi_write_header(AVFormatContext *s) | |||
list2 = ff_start_tag(pb, "LIST"); | |||
ffio_wfourcc(pb, "INFO"); | |||
ff_metadata_conv(&s->metadata, ff_avi_metadata_conv, NULL); | |||
for (i = 0; *ff_avi_tags[i]; i++) { | |||
if ((t = av_dict_get(s->metadata, ff_avi_tags[i], NULL, AV_DICT_MATCH_CASE))) | |||
ff_metadata_conv(&s->metadata, ff_riff_info_conv, NULL); | |||
for (i = 0; *ff_riff_tags[i]; i++) { | |||
if ((t = av_dict_get(s->metadata, ff_riff_tags[i], NULL, AV_DICT_MATCH_CASE))) | |||
avi_write_info_tag(s->pb, t->key, t->value); | |||
} | |||
ff_end_tag(pb, list2); | |||
@@ -90,7 +90,7 @@ static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb, | |||
avio_r8(pb); | |||
avio_r8(pb); | |||
snprintf(buf, sizeof(buf), "%hu", avio_r8(pb)); | |||
snprintf(buf, sizeof(buf), "%d", avio_r8(pb)); | |||
av_dict_set(&c->fc->metadata, key, buf, 0); | |||
return 0; | |||
@@ -101,7 +101,7 @@ static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb, | |||
{ | |||
char buf[16]; | |||
snprintf(buf, sizeof(buf), "%hu", avio_r8(pb)); | |||
snprintf(buf, sizeof(buf), "%d", avio_r8(pb)); | |||
av_dict_set(&c->fc->metadata, key, buf, 0); | |||
return 0; | |||
@@ -117,7 +117,8 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) | |||
{ | |||
MPCContext *c = s->priv_data; | |||
int ret, size, size2, curbits, cur = c->curframe; | |||
int64_t tmp, pos; | |||
unsigned tmp; | |||
int64_t pos; | |||
if (c->curframe >= c->fcount && c->fcount) | |||
return -1; | |||
@@ -134,8 +135,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) | |||
if(curbits <= 12){ | |||
size2 = (tmp >> (12 - curbits)) & 0xFFFFF; | |||
}else{ | |||
tmp = (tmp << 32) | avio_rl32(s->pb); | |||
size2 = (tmp >> (44 - curbits)) & 0xFFFFF; | |||
size2 = (tmp << (curbits - 12) | avio_rl32(s->pb) >> (44 - curbits)) & 0xFFFFF; | |||
} | |||
curbits += 20; | |||
avio_seek(s->pb, pos, SEEK_SET); | |||
@@ -357,6 +357,28 @@ const AVCodecGuid ff_codec_wav_guids[] = { | |||
{CODEC_ID_NONE} | |||
}; | |||
const AVMetadataConv ff_riff_info_conv[] = { | |||
{ "IART", "artist" }, | |||
{ "ICMT", "comment" }, | |||
{ "ICOP", "copyright" }, | |||
{ "ICRD", "date" }, | |||
{ "IGNR", "genre" }, | |||
{ "ILNG", "language" }, | |||
{ "INAM", "title" }, | |||
{ "IPRD", "album" }, | |||
{ "IPRT", "track" }, | |||
{ "ISFT", "encoder" }, | |||
{ "ITCH", "encoded_by"}, | |||
{ 0 }, | |||
}; | |||
const char ff_riff_tags[][5] = { | |||
"IARL", "IART", "ICMS", "ICMT", "ICOP", "ICRD", "ICRP", "IDIM", "IDPI", | |||
"IENG", "IGNR", "IKEY", "ILGT", "ILNG", "IMED", "INAM", "IPLT", "IPRD", | |||
"IPRT", "ISBJ", "ISFT", "ISHP", "ISRC", "ISRF", "ITCH", | |||
{0} | |||
}; | |||
#if CONFIG_MUXERS | |||
int64_t ff_start_tag(AVIOContext *pb, const char *tag) | |||
{ | |||
@@ -656,3 +678,49 @@ enum CodecID ff_codec_guid_get_id(const AVCodecGuid *guids, ff_asf_guid guid) | |||
} | |||
return CODEC_ID_NONE; | |||
} | |||
int ff_read_riff_info(AVFormatContext *s, int64_t size) | |||
{ | |||
int64_t start, end, cur; | |||
AVIOContext *pb = s->pb; | |||
start = avio_tell(pb); | |||
end = start + size; | |||
while ((cur = avio_tell(pb)) >= 0 && cur <= end - 8 /* = tag + size */) { | |||
uint32_t chunk_code; | |||
int64_t chunk_size; | |||
char key[5] = {0}; | |||
char *value; | |||
chunk_code = avio_rl32(pb); | |||
chunk_size = avio_rl32(pb); | |||
if (chunk_size > end || end - chunk_size < cur || chunk_size == UINT_MAX) { | |||
av_log(s, AV_LOG_ERROR, "too big INFO subchunk\n"); | |||
return AVERROR_INVALIDDATA; | |||
} | |||
chunk_size += (chunk_size & 1); | |||
value = av_malloc(chunk_size + 1); | |||
if (!value) { | |||
av_log(s, AV_LOG_ERROR, "out of memory, unable to read INFO tag\n"); | |||
return AVERROR(ENOMEM); | |||
} | |||
AV_WL32(key, chunk_code); | |||
if (avio_read(pb, value, chunk_size) != chunk_size) { | |||
av_freep(key); | |||
av_freep(value); | |||
av_log(s, AV_LOG_ERROR, "premature end of file while reading INFO tag\n"); | |||
return AVERROR_INVALIDDATA; | |||
} | |||
value[chunk_size] = 0; | |||
av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL); | |||
} | |||
return 0; | |||
} |
@@ -31,6 +31,10 @@ | |||
#include "libavcodec/avcodec.h" | |||
#include "avio.h" | |||
#include "internal.h" | |||
#include "metadata.h" | |||
extern const AVMetadataConv ff_riff_info_conv[]; | |||
extern const char ff_riff_tags[][5]; | |||
int64_t ff_start_tag(AVIOContext *pb, const char *tag); | |||
void ff_end_tag(AVIOContext *pb, int64_t start); | |||
@@ -56,6 +60,8 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz | |||
typedef uint8_t ff_asf_guid[16]; | |||
int ff_read_riff_info(AVFormatContext *s, int64_t size); | |||
#define FF_PRI_GUID \ | |||
"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" | |||
#define FF_ARG_GUID(g) \ | |||
@@ -33,7 +33,6 @@ | |||
#include "pcm.h" | |||
#include "riff.h" | |||
#include "avio.h" | |||
#include "avio_internal.h" | |||
#include "metadata.h" | |||
typedef struct { | |||
@@ -231,7 +230,7 @@ AVOutputFormat ff_wav_muxer = { | |||
#if CONFIG_WAV_DEMUXER | |||
static int64_t next_tag(AVIOContext *pb, unsigned int *tag) | |||
static int64_t next_tag(AVIOContext *pb, uint32_t *tag) | |||
{ | |||
*tag = avio_rl32(pb); | |||
return avio_rl32(pb); | |||
@@ -392,7 +391,7 @@ static int wav_read_header(AVFormatContext *s, | |||
int64_t size, av_uninit(data_size); | |||
int64_t sample_count=0; | |||
int rf64; | |||
unsigned int tag; | |||
uint32_t tag, list_type; | |||
AVIOContext *pb = s->pb; | |||
AVStream *st = NULL; | |||
WAVContext *wav = s->priv_data; | |||
@@ -504,6 +503,18 @@ static int wav_read_header(AVFormatContext *s, | |||
avio_rl24(pb); | |||
wav->smv_frames_per_jpeg = avio_rl24(pb); | |||
goto break_loop; | |||
case MKTAG('L', 'I', 'S', 'T'): | |||
list_type = avio_rl32(pb); | |||
if (size <= 4) { | |||
av_log(s, AV_LOG_ERROR, "too short LIST"); | |||
return AVERROR_INVALIDDATA; | |||
} | |||
switch (list_type) { | |||
case MKTAG('I', 'N', 'F', 'O'): | |||
if ((ret = ff_read_riff_info(s, size - 4)) < 0) | |||
return ret; | |||
} | |||
break; | |||
} | |||
/* seek to next tag unless we know that we'll run into EOF */ | |||
@@ -526,6 +537,7 @@ break_loop: | |||
st->duration = sample_count; | |||
ff_metadata_conv_ctx(s, NULL, wav_metadata_conv); | |||
ff_metadata_conv_ctx(s, NULL, ff_riff_info_conv); | |||
return 0; | |||
} | |||