1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility

Originally committed as revision 4453 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2005-07-17 22:24:36 +00:00
parent 4c1a012e9c
commit 01f4895c68
56 changed files with 1023 additions and 1024 deletions

152
ffmpeg.c
View File

@ -493,7 +493,7 @@ static void do_audio_out(AVFormatContext *s,
const int audio_out_size= 4*MAX_AUDIO_PACKET_SIZE; const int audio_out_size= 4*MAX_AUDIO_PACKET_SIZE;
int size_out, frame_bytes, ret; int size_out, frame_bytes, ret;
AVCodecContext *enc= &ost->st->codec; AVCodecContext *enc= ost->st->codec;
/* SC: dynamic allocation of buffers */ /* SC: dynamic allocation of buffers */
if (!audio_buf) if (!audio_buf)
@ -505,9 +505,9 @@ static void do_audio_out(AVFormatContext *s,
if(audio_sync_method){ if(audio_sync_method){
double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
- fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec.channels * 2); - fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec->channels * 2);
double idelta= delta*ist->st->codec.sample_rate / enc->sample_rate; double idelta= delta*ist->st->codec->sample_rate / enc->sample_rate;
int byte_delta= ((int)idelta)*2*ist->st->codec.channels; int byte_delta= ((int)idelta)*2*ist->st->codec->channels;
//FIXME resample delay //FIXME resample delay
if(fabs(delta) > 50){ if(fabs(delta) > 50){
@ -542,19 +542,19 @@ static void do_audio_out(AVFormatContext *s,
assert(ost->audio_resample); assert(ost->audio_resample);
if(verbose > 2) if(verbose > 2)
fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate); fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate);
// fprintf(stderr, "drift:%f len:%d opts:%lld ipts:%lld fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec.channels * 2)); // fprintf(stderr, "drift:%f len:%d opts:%lld ipts:%lld fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec->channels * 2));
av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate); av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate);
} }
} }
}else }else
ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate) ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate)
- fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec.channels * 2); //FIXME wrong - fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec->channels * 2); //FIXME wrong
if (ost->audio_resample) { if (ost->audio_resample) {
buftmp = audio_buf; buftmp = audio_buf;
size_out = audio_resample(ost->resample, size_out = audio_resample(ost->resample,
(short *)buftmp, (short *)buf, (short *)buftmp, (short *)buf,
size / (ist->st->codec.channels * 2)); size / (ist->st->codec->channels * 2));
size_out = size_out * enc->channels * 2; size_out = size_out * enc->channels * 2;
} else { } else {
buftmp = buf; buftmp = buf;
@ -625,7 +625,7 @@ static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void
AVPicture picture_tmp; AVPicture picture_tmp;
uint8_t *buf = 0; uint8_t *buf = 0;
dec = &ist->st->codec; dec = ist->st->codec;
/* deinterlace : must be done before any resize */ /* deinterlace : must be done before any resize */
if (do_deinterlace || using_vhook) { if (do_deinterlace || using_vhook) {
@ -721,7 +721,7 @@ static void do_subtitle_out(AVFormatContext *s,
return; return;
} }
enc = &ost->st->codec; enc = ost->st->codec;
if (!subtitle_out) { if (!subtitle_out) {
subtitle_out = av_malloc(subtitle_out_max_size); subtitle_out = av_malloc(subtitle_out_max_size);
@ -775,8 +775,8 @@ static void do_video_out(AVFormatContext *s,
avcodec_get_frame_defaults(&picture_format_temp); avcodec_get_frame_defaults(&picture_format_temp);
avcodec_get_frame_defaults(&picture_crop_temp); avcodec_get_frame_defaults(&picture_crop_temp);
enc = &ost->st->codec; enc = ost->st->codec;
dec = &ist->st->codec; dec = ist->st->codec;
/* by default, we output a single frame */ /* by default, we output a single frame */
nb_frames = 1; nb_frames = 1;
@ -1049,7 +1049,7 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
} }
ti = MAXINT64; ti = MAXINT64;
enc = &ost->st->codec; enc = ost->st->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO) { if (enc->codec_type == CODEC_TYPE_VIDEO) {
frame_number = ost->frame_number; frame_number = ost->frame_number;
fprintf(fvstats, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame->quality/(float)FF_QP2LAMBDA); fprintf(fvstats, "frame= %5d q= %2.1f ", frame_number, enc->coded_frame->quality/(float)FF_QP2LAMBDA);
@ -1107,7 +1107,7 @@ static void print_report(AVFormatContext **output_files,
for(i=0;i<nb_ostreams;i++) { for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i]; ost = ost_table[i];
os = output_files[ost->file_index]; os = output_files[ost->file_index];
enc = &ost->st->codec; enc = ost->st->codec;
if (vid && enc->codec_type == CODEC_TYPE_VIDEO) { if (vid && enc->codec_type == CODEC_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ",
enc->coded_frame->quality/(float)FF_QP2LAMBDA); enc->coded_frame->quality/(float)FF_QP2LAMBDA);
@ -1220,13 +1220,13 @@ static int output_packet(AVInputStream *ist, int ist_index,
data_size = 0; data_size = 0;
subtitle_to_free = NULL; subtitle_to_free = NULL;
if (ist->decoding_needed) { if (ist->decoding_needed) {
switch(ist->st->codec.codec_type) { switch(ist->st->codec->codec_type) {
case CODEC_TYPE_AUDIO:{ case CODEC_TYPE_AUDIO:{
if(pkt) if(pkt)
samples= av_fast_realloc(samples, &samples_size, FFMAX(pkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE)); samples= av_fast_realloc(samples, &samples_size, FFMAX(pkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE));
/* XXX: could avoid copy if PCM 16 bits with same /* XXX: could avoid copy if PCM 16 bits with same
endianness as CPU */ endianness as CPU */
ret = avcodec_decode_audio(&ist->st->codec, samples, &data_size, ret = avcodec_decode_audio(ist->st->codec, samples, &data_size,
ptr, len); ptr, len);
if (ret < 0) if (ret < 0)
goto fail_decode; goto fail_decode;
@ -1240,14 +1240,14 @@ static int output_packet(AVInputStream *ist, int ist_index,
} }
data_buf = (uint8_t *)samples; data_buf = (uint8_t *)samples;
ist->next_pts += ((int64_t)AV_TIME_BASE/2 * data_size) / ist->next_pts += ((int64_t)AV_TIME_BASE/2 * data_size) /
(ist->st->codec.sample_rate * ist->st->codec.channels); (ist->st->codec->sample_rate * ist->st->codec->channels);
break;} break;}
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
data_size = (ist->st->codec.width * ist->st->codec.height * 3) / 2; data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2;
/* XXX: allocate picture correctly */ /* XXX: allocate picture correctly */
avcodec_get_frame_defaults(&picture); avcodec_get_frame_defaults(&picture);
ret = avcodec_decode_video(&ist->st->codec, ret = avcodec_decode_video(ist->st->codec,
&picture, &got_picture, ptr, len); &picture, &got_picture, ptr, len);
ist->st->quality= picture.quality; ist->st->quality= picture.quality;
if (ret < 0) if (ret < 0)
@ -1256,15 +1256,15 @@ static int output_packet(AVInputStream *ist, int ist_index,
/* no picture yet */ /* no picture yet */
goto discard_packet; goto discard_packet;
} }
if (ist->st->codec.time_base.num != 0) { if (ist->st->codec->time_base.num != 0) {
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec.time_base.num) / ist->st->codec->time_base.num) /
ist->st->codec.time_base.den; ist->st->codec->time_base.den;
} }
len = 0; len = 0;
break; break;
case CODEC_TYPE_SUBTITLE: case CODEC_TYPE_SUBTITLE:
ret = avcodec_decode_subtitle(&ist->st->codec, ret = avcodec_decode_subtitle(ist->st->codec,
&subtitle, &got_subtitle, ptr, len); &subtitle, &got_subtitle, ptr, len);
if (ret < 0) if (ret < 0)
goto fail_decode; goto fail_decode;
@ -1278,16 +1278,16 @@ static int output_packet(AVInputStream *ist, int ist_index,
goto fail_decode; goto fail_decode;
} }
} else { } else {
switch(ist->st->codec.codec_type) { switch(ist->st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec.frame_size) / ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) /
(ist->st->codec.sample_rate * ist->st->codec.channels); (ist->st->codec->sample_rate * ist->st->codec->channels);
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
if (ist->st->codec.time_base.num != 0) { if (ist->st->codec->time_base.num != 0) {
ist->next_pts += ((int64_t)AV_TIME_BASE * ist->next_pts += ((int64_t)AV_TIME_BASE *
ist->st->codec.time_base.num) / ist->st->codec->time_base.num) /
ist->st->codec.time_base.den; ist->st->codec->time_base.den;
} }
break; break;
} }
@ -1298,13 +1298,13 @@ static int output_packet(AVInputStream *ist, int ist_index,
} }
buffer_to_free = NULL; buffer_to_free = NULL;
if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO) { if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) {
pre_process_video_frame(ist, (AVPicture *)&picture, pre_process_video_frame(ist, (AVPicture *)&picture,
&buffer_to_free); &buffer_to_free);
} }
// preprocess audio (volume) // preprocess audio (volume)
if (ist->st->codec.codec_type == CODEC_TYPE_AUDIO) { if (ist->st->codec->codec_type == CODEC_TYPE_AUDIO) {
if (audio_volume != 256) { if (audio_volume != 256) {
short *volp; short *volp;
volp = samples; volp = samples;
@ -1318,8 +1318,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
} }
/* frame rate emulation */ /* frame rate emulation */
if (ist->st->codec.rate_emu) { if (ist->st->codec->rate_emu) {
int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec.time_base.num, 1000000, ist->st->codec.time_base.den); int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec->time_base.num, 1000000, ist->st->codec->time_base.den);
int64_t now = av_gettime() - ist->start; int64_t now = av_gettime() - ist->start;
if (pts > now) if (pts > now)
usleep(pts - now); usleep(pts - now);
@ -1331,8 +1331,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
/* mpeg PTS deordering : if it is a P or I frame, the PTS /* mpeg PTS deordering : if it is a P or I frame, the PTS
is the one of the next displayed one */ is the one of the next displayed one */
/* XXX: add mpeg4 too ? */ /* XXX: add mpeg4 too ? */
if (ist->st->codec.codec_id == CODEC_ID_MPEG1VIDEO) { if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) {
if (ist->st->codec.pict_type != B_TYPE) { if (ist->st->codec->pict_type != B_TYPE) {
int64_t tmp; int64_t tmp;
tmp = ist->last_ip_pts; tmp = ist->last_ip_pts;
ist->last_ip_pts = ist->frac_pts.val; ist->last_ip_pts = ist->frac_pts.val;
@ -1360,7 +1360,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
//ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE; //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
if (ost->encoding_needed) { if (ost->encoding_needed) {
switch(ost->st->codec.codec_type) { switch(ost->st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
do_audio_out(os, ost, ist, data_buf, data_size); do_audio_out(os, ost, ist, data_buf, data_size);
break; break;
@ -1386,12 +1386,12 @@ static int output_packet(AVInputStream *ist, int ist_index,
/* force the input stream PTS */ /* force the input stream PTS */
avcodec_get_frame_defaults(&avframe); avcodec_get_frame_defaults(&avframe);
ost->st->codec.coded_frame= &avframe; ost->st->codec->coded_frame= &avframe;
avframe.key_frame = pkt->flags & PKT_FLAG_KEY; avframe.key_frame = pkt->flags & PKT_FLAG_KEY;
if(ost->st->codec.codec_type == CODEC_TYPE_AUDIO) if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO)
audio_size += data_size; audio_size += data_size;
else if (ost->st->codec.codec_type == CODEC_TYPE_VIDEO) { else if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO) {
video_size += data_size; video_size += data_size;
ost->sync_opts++; ost->sync_opts++;
} }
@ -1411,10 +1411,10 @@ static int output_packet(AVInputStream *ist, int ist_index,
opkt.dts= av_rescale_q(dts + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base); opkt.dts= av_rescale_q(dts + input_files_ts_offset[ist->file_index], AV_TIME_BASE_Q, ost->st->time_base);
} }
opkt.flags= pkt->flags; opkt.flags= pkt->flags;
if(av_parser_change(ist->st->parser, &ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY)) if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & PKT_FLAG_KEY))
opkt.destruct= av_destruct_packet; opkt.destruct= av_destruct_packet;
av_interleaved_write_frame(os, &opkt); av_interleaved_write_frame(os, &opkt);
ost->st->codec.frame_number++; ost->st->codec->frame_number++;
ost->frame_number++; ost->frame_number++;
av_free_packet(&opkt); av_free_packet(&opkt);
} }
@ -1441,12 +1441,12 @@ static int output_packet(AVInputStream *ist, int ist_index,
for(i=0;i<nb_ostreams;i++) { for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i]; ost = ost_table[i];
if (ost->source_index == ist_index) { if (ost->source_index == ist_index) {
AVCodecContext *enc= &ost->st->codec; AVCodecContext *enc= ost->st->codec;
os = output_files[ost->file_index]; os = output_files[ost->file_index];
if(ost->st->codec.codec_type == CODEC_TYPE_AUDIO && enc->frame_size <=1) if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO && enc->frame_size <=1)
continue; continue;
if(ost->st->codec.codec_type == CODEC_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE)) if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
continue; continue;
if (ost->encoding_needed) { if (ost->encoding_needed) {
@ -1455,7 +1455,7 @@ static int output_packet(AVInputStream *ist, int ist_index,
av_init_packet(&pkt); av_init_packet(&pkt);
pkt.stream_index= ost->index; pkt.stream_index= ost->index;
switch(ost->st->codec.codec_type) { switch(ost->st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL); ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL);
audio_size += ret; audio_size += ret;
@ -1546,7 +1546,7 @@ static int av_encode(AVFormatContext **output_files,
ist->discard = 1; /* the stream is discarded by default ist->discard = 1; /* the stream is discarded by default
(changed later) */ (changed later) */
if (ist->st->codec.rate_emu) { if (ist->st->codec->rate_emu) {
ist->start = av_gettime(); ist->start = av_gettime();
ist->frame = 0; ist->frame = 0;
} }
@ -1607,7 +1607,7 @@ static int av_encode(AVFormatContext **output_files,
stream_maps[n-1].stream_index; stream_maps[n-1].stream_index;
/* Sanity check that the stream types match */ /* Sanity check that the stream types match */
if (ist_table[ost->source_index]->st->codec.codec_type != ost->st->codec.codec_type) { if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n", fprintf(stderr, "Codec type mismatch for mapping #%d.%d -> #%d.%d\n",
stream_maps[n-1].file_index, stream_maps[n-1].stream_index, stream_maps[n-1].file_index, stream_maps[n-1].stream_index,
ost->file_index, ost->index); ost->file_index, ost->index);
@ -1620,7 +1620,7 @@ static int av_encode(AVFormatContext **output_files,
for(j=0;j<nb_istreams;j++) { for(j=0;j<nb_istreams;j++) {
ist = ist_table[j]; ist = ist_table[j];
if (ist->discard && if (ist->discard &&
ist->st->codec.codec_type == ost->st->codec.codec_type) { ist->st->codec->codec_type == ost->st->codec->codec_type) {
ost->source_index = j; ost->source_index = j;
found = 1; found = 1;
break; break;
@ -1631,7 +1631,7 @@ static int av_encode(AVFormatContext **output_files,
/* try again and reuse existing stream */ /* try again and reuse existing stream */
for(j=0;j<nb_istreams;j++) { for(j=0;j<nb_istreams;j++) {
ist = ist_table[j]; ist = ist_table[j];
if (ist->st->codec.codec_type == ost->st->codec.codec_type) { if (ist->st->codec->codec_type == ost->st->codec->codec_type) {
ost->source_index = j; ost->source_index = j;
found = 1; found = 1;
} }
@ -1656,8 +1656,8 @@ static int av_encode(AVFormatContext **output_files,
ost = ost_table[i]; ost = ost_table[i];
ist = ist_table[ost->source_index]; ist = ist_table[ost->source_index];
codec = &ost->st->codec; codec = ost->st->codec;
icodec = &ist->st->codec; icodec = ist->st->codec;
if (ost->st->stream_copy) { if (ost->st->stream_copy) {
/* if stream_copy is selected, no need to decode or encode */ /* if stream_copy is selected, no need to decode or encode */
@ -1773,8 +1773,8 @@ static int av_encode(AVFormatContext **output_files,
goto fail; goto fail;
ost->img_resample_ctx = img_resample_full_init( ost->img_resample_ctx = img_resample_full_init(
ost->st->codec.width, ost->st->codec.height, ost->st->codec->width, ost->st->codec->height,
ist->st->codec.width, ist->st->codec.height, ist->st->codec->width, ist->st->codec->height,
frame_topBand, frame_bottomBand, frame_topBand, frame_bottomBand,
frame_leftBand, frame_rightBand, frame_leftBand, frame_rightBand,
frame_padtop, frame_padbottom, frame_padtop, frame_padbottom,
@ -1877,18 +1877,18 @@ static int av_encode(AVFormatContext **output_files,
ost = ost_table[i]; ost = ost_table[i];
if (ost->encoding_needed) { if (ost->encoding_needed) {
AVCodec *codec; AVCodec *codec;
codec = avcodec_find_encoder(ost->st->codec.codec_id); codec = avcodec_find_encoder(ost->st->codec->codec_id);
if (!codec) { if (!codec) {
fprintf(stderr, "Unsupported codec for output stream #%d.%d\n", fprintf(stderr, "Unsupported codec for output stream #%d.%d\n",
ost->file_index, ost->index); ost->file_index, ost->index);
exit(1); exit(1);
} }
if (avcodec_open(&ost->st->codec, codec) < 0) { if (avcodec_open(ost->st->codec, codec) < 0) {
fprintf(stderr, "Error while opening codec for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\n", fprintf(stderr, "Error while opening codec for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\n",
ost->file_index, ost->index); ost->file_index, ost->index);
exit(1); exit(1);
} }
extra_size += ost->st->codec.extradata_size; extra_size += ost->st->codec->extradata_size;
} }
} }
@ -1897,19 +1897,19 @@ static int av_encode(AVFormatContext **output_files,
ist = ist_table[i]; ist = ist_table[i];
if (ist->decoding_needed) { if (ist->decoding_needed) {
AVCodec *codec; AVCodec *codec;
codec = avcodec_find_decoder(ist->st->codec.codec_id); codec = avcodec_find_decoder(ist->st->codec->codec_id);
if (!codec) { if (!codec) {
fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n", fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n",
ist->st->codec.codec_id, ist->file_index, ist->index); ist->st->codec->codec_id, ist->file_index, ist->index);
exit(1); exit(1);
} }
if (avcodec_open(&ist->st->codec, codec) < 0) { if (avcodec_open(ist->st->codec, codec) < 0) {
fprintf(stderr, "Error while opening codec for input stream #%d.%d\n", fprintf(stderr, "Error while opening codec for input stream #%d.%d\n",
ist->file_index, ist->index); ist->file_index, ist->index);
exit(1); exit(1);
} }
//if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO) //if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO)
// ist->st->codec.flags |= CODEC_FLAG_REPEAT_FIELD; // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD;
} }
} }
@ -2010,8 +2010,8 @@ static int av_encode(AVFormatContext **output_files,
ost = ost_table[i]; ost = ost_table[i];
os = output_files[ost->file_index]; os = output_files[ost->file_index];
ist = ist_table[ost->source_index]; ist = ist_table[ost->source_index];
if(ost->st->codec.codec_type == CODEC_TYPE_VIDEO) if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO)
opts = ost->sync_opts * av_q2d(ost->st->codec.time_base); opts = ost->sync_opts * av_q2d(ost->st->codec->time_base);
else else
opts = ost->st->pts.val * av_q2d(ost->st->time_base); opts = ost->st->pts.val * av_q2d(ost->st->time_base);
ipts = (double)ist->pts; ipts = (double)ist->pts;
@ -2025,7 +2025,7 @@ static int av_encode(AVFormatContext **output_files,
if(!input_sync) file_index = ist->file_index; if(!input_sync) file_index = ist->file_index;
} }
} }
if(ost->frame_number >= max_frames[ost->st->codec.codec_type]){ if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
file_index= -1; file_index= -1;
break; break;
} }
@ -2067,7 +2067,7 @@ static int av_encode(AVFormatContext **output_files,
if (ist->discard) if (ist->discard)
goto discard_packet; goto discard_packet;
// fprintf(stderr, "next:%lld dts:%lld off:%lld %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec.codec_type); // fprintf(stderr, "next:%lld dts:%lld off:%lld %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) { if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE) {
int64_t delta= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q) - ist->next_pts; int64_t delta= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q) - ist->next_pts;
if(ABS(delta) > 10LL*AV_TIME_BASE && !copy_ts){ if(ABS(delta) > 10LL*AV_TIME_BASE && !copy_ts){
@ -2123,8 +2123,8 @@ static int av_encode(AVFormatContext **output_files,
for(i=0;i<nb_ostreams;i++) { for(i=0;i<nb_ostreams;i++) {
ost = ost_table[i]; ost = ost_table[i];
if (ost->encoding_needed) { if (ost->encoding_needed) {
av_freep(&ost->st->codec.stats_in); av_freep(&ost->st->codec->stats_in);
avcodec_close(&ost->st->codec); avcodec_close(ost->st->codec);
} }
} }
@ -2132,7 +2132,7 @@ static int av_encode(AVFormatContext **output_files,
for(i=0;i<nb_istreams;i++) { for(i=0;i<nb_istreams;i++) {
ist = ist_table[i]; ist = ist_table[i];
if (ist->decoding_needed) { if (ist->decoding_needed) {
avcodec_close(&ist->st->codec); avcodec_close(ist->st->codec);
} }
} }
@ -3058,7 +3058,7 @@ static void opt_input_file(const char *filename)
/* update the current parameters so that they match the one of the input stream */ /* update the current parameters so that they match the one of the input stream */
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
AVCodecContext *enc = &ic->streams[i]->codec; AVCodecContext *enc = ic->streams[i]->codec;
#if defined(HAVE_THREADS) #if defined(HAVE_THREADS)
if(thread_count>1) if(thread_count>1)
avcodec_thread_init(enc, thread_count); avcodec_thread_init(enc, thread_count);
@ -3154,7 +3154,7 @@ static void check_audio_video_inputs(int *has_video_ptr, int *has_audio_ptr)
for(j=0;j<nb_input_files;j++) { for(j=0;j<nb_input_files;j++) {
ic = input_files[j]; ic = input_files[j];
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
AVCodecContext *enc = &ic->streams[i]->codec; AVCodecContext *enc = ic->streams[i]->codec;
switch(enc->codec_type) { switch(enc->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
has_audio = 1; has_audio = 1;
@ -3187,10 +3187,10 @@ static void new_video_stream(AVFormatContext *oc)
} }
#if defined(HAVE_THREADS) #if defined(HAVE_THREADS)
if(thread_count>1) if(thread_count>1)
avcodec_thread_init(&st->codec, thread_count); avcodec_thread_init(st->codec, thread_count);
#endif #endif
video_enc = &st->codec; video_enc = st->codec;
if(video_codec_tag) if(video_codec_tag)
video_enc->codec_tag= video_codec_tag; video_enc->codec_tag= video_codec_tag;
@ -3473,10 +3473,10 @@ static void new_audio_stream(AVFormatContext *oc)
} }
#if defined(HAVE_THREADS) #if defined(HAVE_THREADS)
if(thread_count>1) if(thread_count>1)
avcodec_thread_init(&st->codec, thread_count); avcodec_thread_init(st->codec, thread_count);
#endif #endif
audio_enc = &st->codec; audio_enc = st->codec;
audio_enc->codec_type = CODEC_TYPE_AUDIO; audio_enc->codec_type = CODEC_TYPE_AUDIO;
if(audio_codec_tag) if(audio_codec_tag)
@ -3535,7 +3535,7 @@ static void opt_new_subtitle_stream(void)
exit(1); exit(1);
} }
subtitle_enc = &st->codec; subtitle_enc = st->codec;
subtitle_enc->codec_type = CODEC_TYPE_SUBTITLE; subtitle_enc->codec_type = CODEC_TYPE_SUBTITLE;
if (subtitle_stream_copy) { if (subtitle_stream_copy) {
st->stream_copy = 1; st->stream_copy = 1;
@ -3732,7 +3732,7 @@ static void prepare_grab(void)
for(j=0;j<nb_output_files;j++) { for(j=0;j<nb_output_files;j++) {
oc = output_files[j]; oc = output_files[j];
for(i=0;i<oc->nb_streams;i++) { for(i=0;i<oc->nb_streams;i++) {
AVCodecContext *enc = &oc->streams[i]->codec; AVCodecContext *enc = oc->streams[i]->codec;
switch(enc->codec_type) { switch(enc->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
if (enc->sample_rate > ap->sample_rate) if (enc->sample_rate > ap->sample_rate)
@ -4041,7 +4041,7 @@ static void opt_target(const char *arg)
int i, j; int i, j;
for(j = 0; j < nb_input_files; j++) { for(j = 0; j < nb_input_files; j++) {
for(i = 0; i < input_files[j]->nb_streams; i++) { for(i = 0; i < input_files[j]->nb_streams; i++) {
AVCodecContext *c = &input_files[j]->streams[i]->codec; AVCodecContext *c = input_files[j]->streams[i]->codec;
if(c->codec_type != CODEC_TYPE_VIDEO) if(c->codec_type != CODEC_TYPE_VIDEO)
continue; continue;
fr = c->time_base.den * 1000 / c->time_base.num; fr = c->time_base.den * 1000 / c->time_base.num;

View File

@ -381,24 +381,24 @@ static void video_image_display(VideoState *is)
vp = &is->pictq[is->pictq_rindex]; vp = &is->pictq[is->pictq_rindex];
if (vp->bmp) { if (vp->bmp) {
/* XXX: use variable in the frame */ /* XXX: use variable in the frame */
if (is->video_st->codec.sample_aspect_ratio.num == 0) if (is->video_st->codec->sample_aspect_ratio.num == 0)
aspect_ratio = 0; aspect_ratio = 0;
else else
aspect_ratio = av_q2d(is->video_st->codec.sample_aspect_ratio) aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio)
* is->video_st->codec.width / is->video_st->codec.height;; * is->video_st->codec->width / is->video_st->codec->height;;
if (aspect_ratio <= 0.0) if (aspect_ratio <= 0.0)
aspect_ratio = (float)is->video_st->codec.width / aspect_ratio = (float)is->video_st->codec->width /
(float)is->video_st->codec.height; (float)is->video_st->codec->height;
/* if an active format is indicated, then it overrides the /* if an active format is indicated, then it overrides the
mpeg format */ mpeg format */
#if 0 #if 0
if (is->video_st->codec.dtg_active_format != is->dtg_active_format) { if (is->video_st->codec->dtg_active_format != is->dtg_active_format) {
is->dtg_active_format = is->video_st->codec.dtg_active_format; is->dtg_active_format = is->video_st->codec->dtg_active_format;
printf("dtg_active_format=%d\n", is->dtg_active_format); printf("dtg_active_format=%d\n", is->dtg_active_format);
} }
#endif #endif
#if 0 #if 0
switch(is->video_st->codec.dtg_active_format) { switch(is->video_st->codec->dtg_active_format) {
case FF_DTG_AFD_SAME: case FF_DTG_AFD_SAME:
default: default:
/* nothing to do */ /* nothing to do */
@ -469,7 +469,7 @@ static void video_audio_display(VideoState *s)
int16_t time_diff; int16_t time_diff;
/* compute display index : center on currently output samples */ /* compute display index : center on currently output samples */
channels = s->audio_st->codec.channels; channels = s->audio_st->codec->channels;
nb_display_channels = channels; nb_display_channels = channels;
if (!s->paused) { if (!s->paused) {
n = 2 * channels; n = 2 * channels;
@ -480,7 +480,7 @@ static void video_audio_display(VideoState *s)
the last buffer computation */ the last buffer computation */
if (audio_callback_time) { if (audio_callback_time) {
time_diff = av_gettime() - audio_callback_time; time_diff = av_gettime() - audio_callback_time;
delay += (time_diff * s->audio_st->codec.sample_rate) / 1000000; delay += (time_diff * s->audio_st->codec->sample_rate) / 1000000;
} }
delay -= s->width / 2; delay -= s->width / 2;
@ -567,8 +567,8 @@ static double get_audio_clock(VideoState *is)
hw_buf_size = audio_write_get_buf_size(is); hw_buf_size = audio_write_get_buf_size(is);
bytes_per_sec = 0; bytes_per_sec = 0;
if (is->audio_st) { if (is->audio_st) {
bytes_per_sec = is->audio_st->codec.sample_rate * bytes_per_sec = is->audio_st->codec->sample_rate *
2 * is->audio_st->codec.channels; 2 * is->audio_st->codec->channels;
} }
if (bytes_per_sec) if (bytes_per_sec)
pts -= (double)hw_buf_size / bytes_per_sec; pts -= (double)hw_buf_size / bytes_per_sec;
@ -767,7 +767,7 @@ static void alloc_picture(void *opaque)
#if 0 #if 0
/* XXX: use generic function */ /* XXX: use generic function */
/* XXX: disable overlay if no hardware acceleration or if RGB format */ /* XXX: disable overlay if no hardware acceleration or if RGB format */
switch(is->video_st->codec.pix_fmt) { switch(is->video_st->codec->pix_fmt) {
case PIX_FMT_YUV420P: case PIX_FMT_YUV420P:
case PIX_FMT_YUV422P: case PIX_FMT_YUV422P:
case PIX_FMT_YUV444P: case PIX_FMT_YUV444P:
@ -781,12 +781,12 @@ static void alloc_picture(void *opaque)
break; break;
} }
#endif #endif
vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec.width, vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width,
is->video_st->codec.height, is->video_st->codec->height,
SDL_YV12_OVERLAY, SDL_YV12_OVERLAY,
screen); screen);
vp->width = is->video_st->codec.width; vp->width = is->video_st->codec->width;
vp->height = is->video_st->codec.height; vp->height = is->video_st->codec->height;
SDL_LockMutex(is->pictq_mutex); SDL_LockMutex(is->pictq_mutex);
vp->allocated = 1; vp->allocated = 1;
@ -815,8 +815,8 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts)
/* alloc or resize hardware picture buffer */ /* alloc or resize hardware picture buffer */
if (!vp->bmp || if (!vp->bmp ||
vp->width != is->video_st->codec.width || vp->width != is->video_st->codec->width ||
vp->height != is->video_st->codec.height) { vp->height != is->video_st->codec->height) {
SDL_Event event; SDL_Event event;
vp->allocated = 0; vp->allocated = 0;
@ -852,8 +852,8 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts)
pict.linesize[1] = vp->bmp->pitches[2]; pict.linesize[1] = vp->bmp->pitches[2];
pict.linesize[2] = vp->bmp->pitches[1]; pict.linesize[2] = vp->bmp->pitches[1];
img_convert(&pict, dst_pix_fmt, img_convert(&pict, dst_pix_fmt,
(AVPicture *)src_frame, is->video_st->codec.pix_fmt, (AVPicture *)src_frame, is->video_st->codec->pix_fmt,
is->video_st->codec.width, is->video_st->codec.height); is->video_st->codec->width, is->video_st->codec->height);
/* update the bitmap content */ /* update the bitmap content */
SDL_UnlockYUVOverlay(vp->bmp); SDL_UnlockYUVOverlay(vp->bmp);
@ -883,7 +883,7 @@ static int output_picture2(VideoState *is, AVFrame *src_frame, double pts1)
pts = is->video_clock; pts = is->video_clock;
} }
/* update video clock for next frame */ /* update video clock for next frame */
frame_delay = av_q2d(is->video_st->codec.time_base); frame_delay = av_q2d(is->video_st->codec->time_base);
/* for MPEG2, the frame can be repeated, so we update the /* for MPEG2, the frame can be repeated, so we update the
clock accordingly */ clock accordingly */
if (src_frame->repeat_pict) { if (src_frame->repeat_pict) {
@ -928,7 +928,7 @@ static int video_thread(void *arg)
pts = av_q2d(is->video_st->time_base)*pkt->dts; pts = av_q2d(is->video_st->time_base)*pkt->dts;
SDL_LockMutex(is->video_decoder_mutex); SDL_LockMutex(is->video_decoder_mutex);
len1 = avcodec_decode_video(&is->video_st->codec, len1 = avcodec_decode_video(is->video_st->codec,
frame, &got_picture, frame, &got_picture,
pkt->data, pkt->size); pkt->data, pkt->size);
SDL_UnlockMutex(is->video_decoder_mutex); SDL_UnlockMutex(is->video_decoder_mutex);
@ -953,7 +953,7 @@ static void update_sample_display(VideoState *is, short *samples, int samples_si
{ {
int size, len, channels; int size, len, channels;
channels = is->audio_st->codec.channels; channels = is->audio_st->codec->channels;
size = samples_size / sizeof(short); size = samples_size / sizeof(short);
while (size > 0) { while (size > 0) {
@ -977,7 +977,7 @@ static int synchronize_audio(VideoState *is, short *samples,
int n, samples_size; int n, samples_size;
double ref_clock; double ref_clock;
n = 2 * is->audio_st->codec.channels; n = 2 * is->audio_st->codec->channels;
samples_size = samples_size1; samples_size = samples_size1;
/* if not master, then we try to remove or add samples to correct the clock */ /* if not master, then we try to remove or add samples to correct the clock */
@ -999,7 +999,7 @@ static int synchronize_audio(VideoState *is, short *samples,
avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef); avg_diff = is->audio_diff_cum * (1.0 - is->audio_diff_avg_coef);
if (fabs(avg_diff) >= is->audio_diff_threshold) { if (fabs(avg_diff) >= is->audio_diff_threshold) {
wanted_size = samples_size + ((int)(diff * is->audio_st->codec.sample_rate) * n); wanted_size = samples_size + ((int)(diff * is->audio_st->codec->sample_rate) * n);
nb_samples = samples_size / n; nb_samples = samples_size / n;
min_size = ((nb_samples * (100 - SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n; min_size = ((nb_samples * (100 - SAMPLE_CORRECTION_PERCENT_MAX)) / 100) * n;
@ -1057,7 +1057,7 @@ static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_pt
/* NOTE: the audio packet can contain several frames */ /* NOTE: the audio packet can contain several frames */
while (is->audio_pkt_size > 0) { while (is->audio_pkt_size > 0) {
SDL_LockMutex(is->audio_decoder_mutex); SDL_LockMutex(is->audio_decoder_mutex);
len1 = avcodec_decode_audio(&is->audio_st->codec, len1 = avcodec_decode_audio(is->audio_st->codec,
(int16_t *)audio_buf, &data_size, (int16_t *)audio_buf, &data_size,
is->audio_pkt_data, is->audio_pkt_size); is->audio_pkt_data, is->audio_pkt_size);
SDL_UnlockMutex(is->audio_decoder_mutex); SDL_UnlockMutex(is->audio_decoder_mutex);
@ -1074,9 +1074,9 @@ static int audio_decode_frame(VideoState *is, uint8_t *audio_buf, double *pts_pt
/* if no pts, then compute it */ /* if no pts, then compute it */
pts = is->audio_clock; pts = is->audio_clock;
*pts_ptr = pts; *pts_ptr = pts;
n = 2 * is->audio_st->codec.channels; n = 2 * is->audio_st->codec->channels;
is->audio_clock += (double)data_size / is->audio_clock += (double)data_size /
(double)(n * is->audio_st->codec.sample_rate); (double)(n * is->audio_st->codec->sample_rate);
#if defined(DEBUG_SYNC) #if defined(DEBUG_SYNC)
{ {
static double last_clock; static double last_clock;
@ -1164,7 +1164,7 @@ static int stream_component_open(VideoState *is, int stream_index)
if (stream_index < 0 || stream_index >= ic->nb_streams) if (stream_index < 0 || stream_index >= ic->nb_streams)
return -1; return -1;
enc = &ic->streams[stream_index]->codec; enc = ic->streams[stream_index]->codec;
/* prepare audio output */ /* prepare audio output */
if (enc->codec_type == CODEC_TYPE_AUDIO) { if (enc->codec_type == CODEC_TYPE_AUDIO) {
@ -1248,7 +1248,7 @@ static void stream_component_close(VideoState *is, int stream_index)
AVFormatContext *ic = is->ic; AVFormatContext *ic = is->ic;
AVCodecContext *enc; AVCodecContext *enc;
enc = &ic->streams[stream_index]->codec; enc = ic->streams[stream_index]->codec;
switch(enc->codec_type) { switch(enc->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
@ -1387,7 +1387,7 @@ static int decode_thread(void *arg)
} }
for(i = 0; i < ic->nb_streams; i++) { for(i = 0; i < ic->nb_streams; i++) {
AVCodecContext *enc = &ic->streams[i]->codec; AVCodecContext *enc = ic->streams[i]->codec;
switch(enc->codec_type) { switch(enc->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
if (audio_index < 0 && !audio_disable) if (audio_index < 0 && !audio_disable)
@ -1455,7 +1455,7 @@ static int decode_thread(void *arg)
} }
if (is->video_stream >= 0) { if (is->video_stream >= 0) {
packet_queue_flush(&is->videoq); packet_queue_flush(&is->videoq);
avcodec_flush_buffers(&ic->streams[video_index]->codec); avcodec_flush_buffers(ic->streams[video_index]->codec);
} }
} }
SDL_UnlockMutex(is->audio_decoder_mutex); SDL_UnlockMutex(is->audio_decoder_mutex);
@ -1594,12 +1594,12 @@ void stream_cycle_channel(VideoState *is, int codec_type)
if (stream_index == start_index) if (stream_index == start_index)
return; return;
st = ic->streams[stream_index]; st = ic->streams[stream_index];
if (st->codec.codec_type == codec_type) { if (st->codec->codec_type == codec_type) {
/* check that parameters are OK */ /* check that parameters are OK */
switch(codec_type) { switch(codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
if (st->codec.sample_rate != 0 && if (st->codec->sample_rate != 0 &&
st->codec.channels != 0) st->codec->channels != 0)
goto the_end; goto the_end;
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:

View File

@ -728,8 +728,8 @@ static void close_connection(HTTPContext *c)
/* close each frame parser */ /* close each frame parser */
for(i=0;i<c->fmt_in->nb_streams;i++) { for(i=0;i<c->fmt_in->nb_streams;i++) {
st = c->fmt_in->streams[i]; st = c->fmt_in->streams[i];
if (st->codec.codec) { if (st->codec->codec) {
avcodec_close(&st->codec); avcodec_close(st->codec);
} }
} }
av_close_input_file(c->fmt_in); av_close_input_file(c->fmt_in);
@ -1002,7 +1002,7 @@ static int find_stream_in_feed(FFStream *feed, AVCodecContext *codec, int bit_ra
int best = -1; int best = -1;
for (i = 0; i < feed->nb_streams; i++) { for (i = 0; i < feed->nb_streams; i++) {
AVCodecContext *feed_codec = &feed->streams[i]->codec; AVCodecContext *feed_codec = feed->streams[i]->codec;
if (feed_codec->codec_id != codec->codec_id || if (feed_codec->codec_id != codec->codec_id ||
feed_codec->sample_rate != codec->sample_rate || feed_codec->sample_rate != codec->sample_rate ||
@ -1044,7 +1044,7 @@ static int modify_current_stream(HTTPContext *c, char *rates)
return 0; return 0;
for (i = 0; i < req->nb_streams; i++) { for (i = 0; i < req->nb_streams; i++) {
AVCodecContext *codec = &req->streams[i]->codec; AVCodecContext *codec = req->streams[i]->codec;
switch(rates[i]) { switch(rates[i]) {
case 0: case 0:
@ -1659,10 +1659,10 @@ static void compute_stats(HTTPContext *c)
for(i=0;i<stream->nb_streams;i++) { for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i]; AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec.codec_id); AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
audio_bit_rate += st->codec.bit_rate; audio_bit_rate += st->codec->bit_rate;
if (codec) { if (codec) {
if (*audio_codec_name) if (*audio_codec_name)
audio_codec_name_extra = "..."; audio_codec_name_extra = "...";
@ -1670,7 +1670,7 @@ static void compute_stats(HTTPContext *c)
} }
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
video_bit_rate += st->codec.bit_rate; video_bit_rate += st->codec->bit_rate;
if (codec) { if (codec) {
if (*video_codec_name) if (*video_codec_name)
video_codec_name_extra = "..."; video_codec_name_extra = "...";
@ -1678,7 +1678,7 @@ static void compute_stats(HTTPContext *c)
} }
break; break;
case CODEC_TYPE_DATA: case CODEC_TYPE_DATA:
video_bit_rate += st->codec.bit_rate; video_bit_rate += st->codec->bit_rate;
break; break;
default: default:
av_abort(); av_abort();
@ -1744,26 +1744,26 @@ static void compute_stats(HTTPContext *c)
for (i = 0; i < stream->nb_streams; i++) { for (i = 0; i < stream->nb_streams; i++) {
AVStream *st = stream->streams[i]; AVStream *st = stream->streams[i];
AVCodec *codec = avcodec_find_encoder(st->codec.codec_id); AVCodec *codec = avcodec_find_encoder(st->codec->codec_id);
const char *type = "unknown"; const char *type = "unknown";
char parameters[64]; char parameters[64];
parameters[0] = 0; parameters[0] = 0;
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
type = "audio"; type = "audio";
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
type = "video"; type = "video";
snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec.width, st->codec.height, snprintf(parameters, sizeof(parameters), "%dx%d, q=%d-%d, fps=%d", st->codec->width, st->codec->height,
st->codec.qmin, st->codec.qmax, st->codec.time_base.den / st->codec.time_base.num); st->codec->qmin, st->codec->qmax, st->codec->time_base.den / st->codec->time_base.num);
break; break;
default: default:
av_abort(); av_abort();
} }
url_fprintf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n", url_fprintf(pb, "<tr><td align=right>%d<td>%s<td align=right>%d<td>%s<td>%s\n",
i, type, st->codec.bit_rate/1000, codec ? codec->name : "", parameters); i, type, st->codec->bit_rate/1000, codec ? codec->name : "", parameters);
} }
url_fprintf(pb, "</table>\n"); url_fprintf(pb, "</table>\n");
@ -1786,7 +1786,7 @@ static void compute_stats(HTTPContext *c)
for(i=0;i<stream->nb_streams;i++) { for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i]; AVStream *st = stream->streams[i];
FeedData *fdata = st->priv_data; FeedData *fdata = st->priv_data;
enc = &st->codec; enc = st->codec;
avcodec_string(buf, sizeof(buf), enc); avcodec_string(buf, sizeof(buf), enc);
avg = fdata->avg_frame_size * (float)enc->rate * 8.0; avg = fdata->avg_frame_size * (float)enc->rate * 8.0;
@ -1822,10 +1822,10 @@ static void compute_stats(HTTPContext *c)
if (c1->stream) { if (c1->stream) {
for (j = 0; j < c1->stream->nb_streams; j++) { for (j = 0; j < c1->stream->nb_streams; j++) {
if (!c1->stream->feed) { if (!c1->stream->feed) {
bitrate += c1->stream->streams[j]->codec.bit_rate; bitrate += c1->stream->streams[j]->codec->bit_rate;
} else { } else {
if (c1->feed_streams[j] >= 0) { if (c1->feed_streams[j] >= 0) {
bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec.bit_rate; bitrate += c1->stream->feed->streams[c1->feed_streams[j]]->codec->bit_rate;
} }
} }
} }
@ -1867,12 +1867,12 @@ static void open_parser(AVFormatContext *s, int i)
AVStream *st = s->streams[i]; AVStream *st = s->streams[i];
AVCodec *codec; AVCodec *codec;
if (!st->codec.codec) { if (!st->codec->codec) {
codec = avcodec_find_decoder(st->codec.codec_id); codec = avcodec_find_decoder(st->codec->codec_id);
if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) { if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) {
st->codec.parse_only = 1; st->codec->parse_only = 1;
if (avcodec_open(&st->codec, codec) < 0) { if (avcodec_open(st->codec, codec) < 0) {
st->codec.parse_only = 0; st->codec->parse_only = 0;
} }
} }
} }
@ -1935,7 +1935,7 @@ static int open_input_stream(HTTPContext *c, const char *info)
c->pts_stream_index = 0; c->pts_stream_index = 0;
for(i=0;i<c->stream->nb_streams;i++) { for(i=0;i<c->stream->nb_streams;i++) {
if (c->pts_stream_index == 0 && if (c->pts_stream_index == 0 &&
c->stream->streams[i]->codec.codec_type == CODEC_TYPE_VIDEO) { c->stream->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) {
c->pts_stream_index = i; c->pts_stream_index = i;
} }
} }
@ -2010,12 +2010,12 @@ static int http_prepare_data(HTTPContext *c)
*st = *src; *st = *src;
st->priv_data = 0; st->priv_data = 0;
st->codec.frame_number = 0; /* XXX: should be done in st->codec->frame_number = 0; /* XXX: should be done in
AVStream, not in codec */ AVStream, not in codec */
/* I'm pretty sure that this is not correct... /* I'm pretty sure that this is not correct...
* However, without it, we crash * However, without it, we crash
*/ */
st->codec.coded_frame = &dummy_frame; st->codec->coded_frame = &dummy_frame;
} }
c->got_key_frame = 0; c->got_key_frame = 0;
@ -2144,13 +2144,13 @@ static int http_prepare_data(HTTPContext *c)
av_free_packet(&pkt); av_free_packet(&pkt);
break; break;
} }
codec = &ctx->streams[0]->codec; codec = ctx->streams[0]->codec;
/* only one stream per RTP connection */ /* only one stream per RTP connection */
pkt.stream_index = 0; pkt.stream_index = 0;
} else { } else {
ctx = &c->fmt_ctx; ctx = &c->fmt_ctx;
/* Fudge here */ /* Fudge here */
codec = &ctx->streams[pkt.stream_index]->codec; codec = ctx->streams[pkt.stream_index]->codec;
} }
codec->coded_frame->key_frame = ((pkt.flags & PKT_FLAG_KEY) != 0); codec->coded_frame->key_frame = ((pkt.flags & PKT_FLAG_KEY) != 0);
@ -2462,8 +2462,8 @@ static int http_receive_data(HTTPContext *c)
goto fail; goto fail;
} }
for (i = 0; i < s.nb_streams; i++) { for (i = 0; i < s.nb_streams; i++) {
memcpy(&feed->streams[i]->codec, memcpy(feed->streams[i]->codec,
&s.streams[i]->codec, sizeof(AVCodecContext)); s.streams[i]->codec, sizeof(AVCodecContext));
} }
av_freep(&s.priv_data); av_freep(&s.priv_data);
} }
@ -2638,10 +2638,10 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
private_payload_type = RTP_PT_PRIVATE; private_payload_type = RTP_PT_PRIVATE;
for(i = 0; i < stream->nb_streams; i++) { for(i = 0; i < stream->nb_streams; i++) {
st = stream->streams[i]; st = stream->streams[i];
if (st->codec.codec_id == CODEC_ID_MPEG2TS) { if (st->codec->codec_id == CODEC_ID_MPEG2TS) {
mediatype = "video"; mediatype = "video";
} else { } else {
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
mediatype = "audio"; mediatype = "audio";
break; break;
@ -2655,7 +2655,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
} }
/* NOTE: the port indication is not correct in case of /* NOTE: the port indication is not correct in case of
unicast. It is not an issue because RTSP gives it */ unicast. It is not an issue because RTSP gives it */
payload_type = rtp_get_payload_type(&st->codec); payload_type = rtp_get_payload_type(st->codec);
if (payload_type < 0) if (payload_type < 0)
payload_type = private_payload_type++; payload_type = private_payload_type++;
if (stream->is_multicast) { if (stream->is_multicast) {
@ -2667,17 +2667,17 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
mediatype, port, payload_type); mediatype, port, payload_type);
if (payload_type >= RTP_PT_PRIVATE) { if (payload_type >= RTP_PT_PRIVATE) {
/* for private payload type, we need to give more info */ /* for private payload type, we need to give more info */
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MPEG4: case CODEC_ID_MPEG4:
{ {
uint8_t *data; uint8_t *data;
url_fprintf(pb, "a=rtpmap:%d MP4V-ES/%d\n", url_fprintf(pb, "a=rtpmap:%d MP4V-ES/%d\n",
payload_type, 90000); payload_type, 90000);
/* we must also add the mpeg4 header */ /* we must also add the mpeg4 header */
data = st->codec.extradata; data = st->codec->extradata;
if (data) { if (data) {
url_fprintf(pb, "a=fmtp:%d config=", payload_type); url_fprintf(pb, "a=fmtp:%d config=", payload_type);
for(j=0;j<st->codec.extradata_size;j++) { for(j=0;j<st->codec->extradata_size;j++) {
url_fprintf(pb, "%02x", data[j]); url_fprintf(pb, "%02x", data[j]);
} }
url_fprintf(pb, "\n"); url_fprintf(pb, "\n");
@ -3222,8 +3222,8 @@ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec)
if (!fst) if (!fst)
return NULL; return NULL;
fst->priv_data = av_mallocz(sizeof(FeedData)); fst->priv_data = av_mallocz(sizeof(FeedData));
memcpy(&fst->codec, codec, sizeof(AVCodecContext)); memcpy(fst->codec, codec, sizeof(AVCodecContext));
fst->codec.coded_frame = &dummy_frame; fst->codec->coded_frame = &dummy_frame;
fst->index = stream->nb_streams; fst->index = stream->nb_streams;
av_set_pts_info(fst, 33, 1, 90000); av_set_pts_info(fst, 33, 1, 90000);
stream->streams[stream->nb_streams++] = fst; stream->streams[stream->nb_streams++] = fst;
@ -3237,10 +3237,10 @@ static int add_av_stream(FFStream *feed, AVStream *st)
AVCodecContext *av, *av1; AVCodecContext *av, *av1;
int i; int i;
av = &st->codec; av = st->codec;
for(i=0;i<feed->nb_streams;i++) { for(i=0;i<feed->nb_streams;i++) {
st = feed->streams[i]; st = feed->streams[i];
av1 = &st->codec; av1 = st->codec;
if (av1->codec_id == av->codec_id && if (av1->codec_id == av->codec_id &&
av1->codec_type == av->codec_type && av1->codec_type == av->codec_type &&
av1->bit_rate == av->bit_rate) { av1->bit_rate == av->bit_rate) {
@ -3297,8 +3297,8 @@ static void extract_mpeg4_header(AVFormatContext *infile)
mpeg4_count = 0; mpeg4_count = 0;
for(i=0;i<infile->nb_streams;i++) { for(i=0;i<infile->nb_streams;i++) {
st = infile->streams[i]; st = infile->streams[i];
if (st->codec.codec_id == CODEC_ID_MPEG4 && if (st->codec->codec_id == CODEC_ID_MPEG4 &&
st->codec.extradata_size == 0) { st->codec->extradata_size == 0) {
mpeg4_count++; mpeg4_count++;
} }
} }
@ -3310,9 +3310,9 @@ static void extract_mpeg4_header(AVFormatContext *infile)
if (av_read_packet(infile, &pkt) < 0) if (av_read_packet(infile, &pkt) < 0)
break; break;
st = infile->streams[pkt.stream_index]; st = infile->streams[pkt.stream_index];
if (st->codec.codec_id == CODEC_ID_MPEG4 && if (st->codec->codec_id == CODEC_ID_MPEG4 &&
st->codec.extradata_size == 0) { st->codec->extradata_size == 0) {
av_freep(&st->codec.extradata); av_freep(&st->codec->extradata);
/* fill extradata with the header */ /* fill extradata with the header */
/* XXX: we make hard suppositions here ! */ /* XXX: we make hard suppositions here ! */
p = pkt.data; p = pkt.data;
@ -3322,9 +3322,9 @@ static void extract_mpeg4_header(AVFormatContext *infile)
p[2] == 0x01 && p[3] == 0xb6) { p[2] == 0x01 && p[3] == 0xb6) {
size = p - pkt.data; size = p - pkt.data;
// av_hex_dump(pkt.data, size); // av_hex_dump(pkt.data, size);
st->codec.extradata = av_malloc(size); st->codec->extradata = av_malloc(size);
st->codec.extradata_size = size; st->codec->extradata_size = size;
memcpy(st->codec.extradata, pkt.data, size); memcpy(st->codec->extradata, pkt.data, size);
break; break;
} }
p++; p++;
@ -3376,7 +3376,7 @@ static void build_file_streams(void)
extract_mpeg4_header(infile); extract_mpeg4_header(infile);
for(i=0;i<infile->nb_streams;i++) { for(i=0;i<infile->nb_streams;i++) {
add_av_stream1(stream, &infile->streams[i]->codec); add_av_stream1(stream, infile->streams[i]->codec);
} }
av_close_input_file(infile); av_close_input_file(infile);
} }
@ -3441,8 +3441,8 @@ static void build_feed_streams(void)
} else { } else {
AVCodecContext *ccf, *ccs; AVCodecContext *ccf, *ccs;
ccf = &sf->codec; ccf = sf->codec;
ccs = &ss->codec; ccs = ss->codec;
#define CHECK_CODEC(x) (ccf->x != ccs->x) #define CHECK_CODEC(x) (ccf->x != ccs->x)
if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) { if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) {
@ -3550,10 +3550,10 @@ static void compute_bandwidth(void)
bandwidth = 0; bandwidth = 0;
for(i=0;i<stream->nb_streams;i++) { for(i=0;i<stream->nb_streams;i++) {
AVStream *st = stream->streams[i]; AVStream *st = stream->streams[i];
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
bandwidth += st->codec.bit_rate; bandwidth += st->codec->bit_rate;
break; break;
default: default:
break; break;
@ -3665,7 +3665,7 @@ static void add_codec(FFStream *stream, AVCodecContext *av)
if (!st) if (!st)
return; return;
stream->streams[stream->nb_streams++] = st; stream->streams[stream->nb_streams++] = st;
memcpy(&st->codec, av, sizeof(AVCodecContext)); memcpy(st->codec, av, sizeof(AVCodecContext));
} }
static int opt_audio_codec(const char *arg) static int opt_audio_codec(const char *arg)

View File

@ -166,11 +166,11 @@ static int fourxm_read_header(AVFormatContext *s,
fourxm->video_stream_index = st->index; fourxm->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_4XM; st->codec->codec_id = CODEC_ID_4XM;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = fourxm->width; st->codec->width = fourxm->width;
st->codec.height = fourxm->height; st->codec->height = fourxm->height;
} else if (fourcc_tag == strk_TAG) { } else if (fourcc_tag == strk_TAG) {
/* check that there is enough data */ /* check that there is enough data */
@ -205,20 +205,20 @@ static int fourxm_read_header(AVFormatContext *s,
fourxm->tracks[current_track].stream_index = st->index; fourxm->tracks[current_track].stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = 1; st->codec->codec_tag = 1;
st->codec.channels = fourxm->tracks[current_track].channels; st->codec->channels = fourxm->tracks[current_track].channels;
st->codec.sample_rate = fourxm->tracks[current_track].sample_rate; st->codec->sample_rate = fourxm->tracks[current_track].sample_rate;
st->codec.bits_per_sample = fourxm->tracks[current_track].bits; st->codec->bits_per_sample = fourxm->tracks[current_track].bits;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample; st->codec->bits_per_sample;
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
if (fourxm->tracks[current_track].adpcm) if (fourxm->tracks[current_track].adpcm)
st->codec.codec_id = CODEC_ID_ADPCM_4XM; st->codec->codec_id = CODEC_ID_ADPCM_4XM;
else if (st->codec.bits_per_sample == 8) else if (st->codec->bits_per_sample == 8)
st->codec.codec_id = CODEC_ID_PCM_U8; st->codec->codec_id = CODEC_ID_PCM_U8;
else else
st->codec.codec_id = CODEC_ID_PCM_S16LE; st->codec->codec_id = CODEC_ID_PCM_S16LE;
} }
} }

View File

@ -31,7 +31,7 @@ static const unsigned char AMRWB_header [] = "#!AMR-WB\n";
static int amr_write_header(AVFormatContext *s) static int amr_write_header(AVFormatContext *s)
{ {
ByteIOContext *pb = &s->pb; ByteIOContext *pb = &s->pb;
AVCodecContext *enc = &s->streams[0]->codec; AVCodecContext *enc = s->streams[0]->codec;
s->priv_data = NULL; s->priv_data = NULL;
@ -100,11 +100,11 @@ static int amr_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
} }
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = MKTAG('s', 'a', 'w', 'b'); st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b');
st->codec.codec_id = CODEC_ID_AMR_WB; st->codec->codec_id = CODEC_ID_AMR_WB;
st->codec.channels = 1; st->codec->channels = 1;
st->codec.sample_rate = 16000; st->codec->sample_rate = 16000;
} }
else else
{ {
@ -114,11 +114,11 @@ static int amr_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
} }
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = MKTAG('s', 'a', 'm', 'r'); st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r');
st->codec.codec_id = CODEC_ID_AMR_NB; st->codec->codec_id = CODEC_ID_AMR_NB;
st->codec.channels = 1; st->codec->channels = 1;
st->codec.sample_rate = 8000; st->codec->sample_rate = 8000;
} }
return 0; return 0;
@ -129,7 +129,7 @@ static int amr_read_header(AVFormatContext *s,
static int amr_read_packet(AVFormatContext *s, static int amr_read_packet(AVFormatContext *s,
AVPacket *pkt) AVPacket *pkt)
{ {
AVCodecContext *enc = &s->streams[0]->codec; AVCodecContext *enc = s->streams[0]->codec;
if (enc->codec_id == CODEC_ID_AMR_NB) if (enc->codec_id == CODEC_ID_AMR_NB)
{ {

View File

@ -289,7 +289,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
bit_rate = 0; bit_rate = 0;
for(n=0;n<s->nb_streams;n++) { for(n=0;n<s->nb_streams;n++) {
enc = &s->streams[n]->codec; enc = s->streams[n]->codec;
av_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */ av_set_pts_info(s->streams[n], 32, 1, 1000); /* 32 bit pts in ms */
@ -353,7 +353,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
int er_spr_len = 0; int er_spr_len = 0;
// ASFStream *stream = &asf->streams[n]; // ASFStream *stream = &asf->streams[n];
enc = &s->streams[n]->codec; enc = s->streams[n]->codec;
asf->streams[n].num = n + 1; asf->streams[n].num = n + 1;
asf->streams[n].seq = 0; asf->streams[n].seq = 0;
@ -437,7 +437,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
for(n=0;n<s->nb_streams;n++) { for(n=0;n<s->nb_streams;n++) {
AVCodec *p; AVCodec *p;
enc = &s->streams[n]->codec; enc = s->streams[n]->codec;
p = avcodec_find_encoder(enc->codec_id); p = avcodec_find_encoder(enc->codec_id);
put_le16(pb, asf->streams[n].num); put_le16(pb, asf->streams[n].num);
@ -730,7 +730,7 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
int64_t packet_st,pts; int64_t packet_st,pts;
int start_sec,i; int start_sec,i;
codec = &s->streams[pkt->stream_index]->codec; codec = s->streams[pkt->stream_index]->codec;
stream = &asf->streams[pkt->stream_index]; stream = &asf->streams[pkt->stream_index];
//XXX /FIXME use duration from AVPacket (quick hack by) //XXX /FIXME use duration from AVPacket (quick hack by)

View File

@ -216,9 +216,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
asf->asfid2avid[st->id] = s->nb_streams - 1; asf->asfid2avid[st->id] = s->nb_streams - 1;
get_le32(pb); get_le32(pb);
st->codec.codec_type = type; st->codec->codec_type = type;
if (type == CODEC_TYPE_AUDIO) { if (type == CODEC_TYPE_AUDIO) {
get_wav_header(pb, &st->codec, type_specific_size); get_wav_header(pb, st->codec, type_specific_size);
st->need_parsing = 1; st->need_parsing = 1;
/* We have to init the frame size at some point .... */ /* We have to init the frame size at some point .... */
pos2 = url_ftell(pb); pos2 = url_ftell(pb);
@ -237,9 +237,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
|| (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)) || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1))
asf_st->ds_span = 0; // disable descrambling asf_st->ds_span = 0; // disable descrambling
} }
switch (st->codec.codec_id) { switch (st->codec->codec_id) {
case CODEC_ID_MP3: case CODEC_ID_MP3:
st->codec.frame_size = MPA_FRAME_SIZE; st->codec->frame_size = MPA_FRAME_SIZE;
break; break;
case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16BE:
@ -249,11 +249,11 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
case CODEC_ID_PCM_U8: case CODEC_ID_PCM_U8:
case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_MULAW:
st->codec.frame_size = 1; st->codec->frame_size = 1;
break; break;
default: default:
/* This is probably wrong, but it prevents a crash later */ /* This is probably wrong, but it prevents a crash later */
st->codec.frame_size = 1; st->codec->frame_size = 1;
break; break;
} }
} else { } else {
@ -262,38 +262,38 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_byte(pb); get_byte(pb);
size = get_le16(pb); /* size */ size = get_le16(pb); /* size */
sizeX= get_le32(pb); /* size */ sizeX= get_le32(pb); /* size */
st->codec.width = get_le32(pb); st->codec->width = get_le32(pb);
st->codec.height = get_le32(pb); st->codec->height = get_le32(pb);
/* not available for asf */ /* not available for asf */
get_le16(pb); /* panes */ get_le16(pb); /* panes */
st->codec.bits_per_sample = get_le16(pb); /* depth */ st->codec->bits_per_sample = get_le16(pb); /* depth */
tag1 = get_le32(pb); tag1 = get_le32(pb);
url_fskip(pb, 20); url_fskip(pb, 20);
// av_log(NULL, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX); // av_log(NULL, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
size= sizeX; size= sizeX;
if (size > 40) { if (size > 40) {
st->codec.extradata_size = size - 40; st->codec->extradata_size = size - 40;
st->codec.extradata = av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size); get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
} }
/* Extract palette from extradata if bpp <= 8 */ /* Extract palette from extradata if bpp <= 8 */
/* This code assumes that extradata contains only palette */ /* This code assumes that extradata contains only palette */
/* This is true for all paletted codecs implemented in ffmpeg */ /* This is true for all paletted codecs implemented in ffmpeg */
if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) {
st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++) for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]); st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
#else #else
memcpy(st->codec.palctrl->palette, st->codec.extradata, memcpy(st->codec->palctrl->palette, st->codec->extradata,
FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
#endif #endif
st->codec.palctrl->palette_changed = 1; st->codec->palctrl->palette_changed = 1;
} }
st->codec.codec_tag = tag1; st->codec->codec_tag = tag1;
st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
if(tag1 == MKTAG('D', 'V', 'R', ' ')) if(tag1 == MKTAG('D', 'V', 'R', ' '))
st->need_parsing = 1; st->need_parsing = 1;
} }
@ -398,7 +398,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
AVStream *st = s->streams[i]; AVStream *st = s->streams[i];
if (st) { if (st) {
av_free(st->priv_data); av_free(st->priv_data);
av_free(st->codec.extradata); av_free(st->codec->extradata);
} }
av_free(st); av_free(st);
} }
@ -608,8 +608,8 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
asf_st->packet_pos= asf->packet_pos; asf_st->packet_pos= asf->packet_pos;
//printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
//asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY, //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY,
//s->streams[asf->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size); //s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size);
if (s->streams[asf->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO) if (s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO)
asf->packet_key_frame = 1; asf->packet_key_frame = 1;
if (asf->packet_key_frame) if (asf->packet_key_frame)
asf_st->pkt.flags |= PKT_FLAG_KEY; asf_st->pkt.flags |= PKT_FLAG_KEY;
@ -666,8 +666,8 @@ static int asf_read_close(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i]; AVStream *st = s->streams[i];
av_free(st->priv_data); av_free(st->priv_data);
av_free(st->codec.extradata); av_free(st->codec->extradata);
av_free(st->codec.palctrl); av_free(st->codec->palctrl);
} }
return 0; return 0;
} }

View File

@ -63,7 +63,7 @@ static int au_write_header(AVFormatContext *s)
s->priv_data = NULL; s->priv_data = NULL;
/* format header */ /* format header */
if (put_au_header(pb, &s->streams[0]->codec) < 0) { if (put_au_header(pb, s->streams[0]->codec) < 0) {
return -1; return -1;
} }
@ -143,11 +143,11 @@ static int au_read_header(AVFormatContext *s,
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
return -1; return -1;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = id; st->codec->codec_tag = id;
st->codec.codec_id = codec; st->codec->codec_id = codec;
st->codec.channels = channels; st->codec->channels = channels;
st->codec.sample_rate = rate; st->codec->sample_rate = rate;
av_set_pts_info(st, 64, 1, rate); av_set_pts_info(st, 64, 1, rate);
return 0; return 0;
} }

View File

@ -162,8 +162,8 @@ static int audio_write_header(AVFormatContext *s1)
int ret; int ret;
st = s1->streams[0]; st = s1->streams[0];
s->sample_rate = st->codec.sample_rate; s->sample_rate = st->codec->sample_rate;
s->channels = st->codec.channels; s->channels = st->codec->channels;
ret = audio_open(s, 1, NULL); ret = audio_open(s, 1, NULL);
if (ret < 0) { if (ret < 0) {
return AVERROR_IO; return AVERROR_IO;
@ -234,10 +234,10 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
} }
/* take real parameters */ /* take real parameters */
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = s->codec_id; st->codec->codec_id = s->codec_id;
st->codec.sample_rate = s->sample_rate; st->codec->sample_rate = s->sample_rate;
st->codec.channels = s->channels; st->codec->channels = s->channels;
av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */ av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */
return 0; return 0;

View File

@ -5,7 +5,7 @@
extern "C" { extern "C" {
#endif #endif
#define LIBAVFORMAT_BUILD 4628 #define LIBAVFORMAT_BUILD 4629
#define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVFORMAT_VERSION FFMPEG_VERSION #define LIBAVFORMAT_VERSION FFMPEG_VERSION
@ -216,7 +216,7 @@ typedef struct AVIndexEntry {
typedef struct AVStream { typedef struct AVStream {
int index; /* stream index in AVFormatContext */ int index; /* stream index in AVFormatContext */
int id; /* format specific stream id */ int id; /* format specific stream id */
AVCodecContext codec; /* codec context */ AVCodecContext *codec; /* codec context */
/** /**
* real base frame rate of the stream. * real base frame rate of the stream.
* for example if the timebase is 1/90000 and all frames have either * for example if the timebase is 1/90000 and all frames have either

View File

@ -178,7 +178,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto fail; goto fail;
ast = s->streams[0]->priv_data; ast = s->streams[0]->priv_data;
av_freep(&s->streams[0]->codec.extradata); av_freep(&s->streams[0]->codec->extradata);
av_freep(&s->streams[0]); av_freep(&s->streams[0]);
s->nb_streams = 0; s->nb_streams = 0;
avi->dv_demux = dv_init_demux(s); avi->dv_demux = dv_init_demux(s);
@ -199,7 +199,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
} }
st = s->streams[stream_index]; st = s->streams[stream_index];
ast = st->priv_data; ast = st->priv_data;
st->codec.stream_codec_tag= handler; st->codec->stream_codec_tag= handler;
get_le32(pb); /* flags */ get_le32(pb); /* flags */
get_le16(pb); /* priority */ get_le16(pb); /* priority */
@ -259,10 +259,10 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
switch(codec_type) { switch(codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
get_le32(pb); /* size */ get_le32(pb); /* size */
st->codec.width = get_le32(pb); st->codec->width = get_le32(pb);
st->codec.height = get_le32(pb); st->codec->height = get_le32(pb);
get_le16(pb); /* panes */ get_le16(pb); /* panes */
st->codec.bits_per_sample= get_le16(pb); /* depth */ st->codec->bits_per_sample= get_le16(pb); /* depth */
tag1 = get_le32(pb); tag1 = get_le32(pb);
get_le32(pb); /* ImageSize */ get_le32(pb); /* ImageSize */
get_le32(pb); /* XPelsPerMeter */ get_le32(pb); /* XPelsPerMeter */
@ -271,41 +271,41 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_le32(pb); /* ClrImportant */ get_le32(pb); /* ClrImportant */
if(size > 10*4 && size<(1<<30)){ if(size > 10*4 && size<(1<<30)){
st->codec.extradata_size= size - 10*4; st->codec->extradata_size= size - 10*4;
st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size); get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
} }
if(st->codec.extradata_size & 1) //FIXME check if the encoder really did this correctly if(st->codec->extradata_size & 1) //FIXME check if the encoder really did this correctly
get_byte(pb); get_byte(pb);
/* Extract palette from extradata if bpp <= 8 */ /* Extract palette from extradata if bpp <= 8 */
/* This code assumes that extradata contains only palette */ /* This code assumes that extradata contains only palette */
/* This is true for all paletted codecs implemented in ffmpeg */ /* This is true for all paletted codecs implemented in ffmpeg */
if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) {
st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++) for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]); st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
#else #else
memcpy(st->codec.palctrl->palette, st->codec.extradata, memcpy(st->codec->palctrl->palette, st->codec->extradata,
FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
#endif #endif
st->codec.palctrl->palette_changed = 1; st->codec->palctrl->palette_changed = 1;
} }
#ifdef DEBUG #ifdef DEBUG
print_tag("video", tag1, 0); print_tag("video", tag1, 0);
#endif #endif
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_tag = tag1; st->codec->codec_tag = tag1;
st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
if (st->codec.codec_id == CODEC_ID_XAN_WC4) if (st->codec->codec_id == CODEC_ID_XAN_WC4)
xan_video = 1; xan_video = 1;
// url_fskip(pb, size - 5 * 4); // url_fskip(pb, size - 5 * 4);
break; break;
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
get_wav_header(pb, &st->codec, size); get_wav_header(pb, st->codec, size);
if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */ if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
url_fskip(pb, 1); url_fskip(pb, 1);
/* special case time: To support Xan DPCM, hardcode /* special case time: To support Xan DPCM, hardcode
@ -314,12 +314,12 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* force parsing as several audio frames can be in /* force parsing as several audio frames can be in
one packet */ one packet */
if (xan_video) if (xan_video)
st->codec.codec_id = CODEC_ID_XAN_DPCM; st->codec->codec_id = CODEC_ID_XAN_DPCM;
break; break;
default: default:
st->codec.codec_type = CODEC_TYPE_DATA; st->codec->codec_type = CODEC_TYPE_DATA;
st->codec.codec_id= CODEC_ID_NONE; st->codec->codec_id= CODEC_ID_NONE;
st->codec.codec_tag= 0; st->codec->codec_tag= 0;
url_fskip(pb, size); url_fskip(pb, size);
break; break;
} }
@ -337,7 +337,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (stream_index != s->nb_streams - 1) { if (stream_index != s->nb_streams - 1) {
fail: fail:
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
av_freep(&s->streams[i]->codec.extradata); av_freep(&s->streams[i]->codec->extradata);
av_freep(&s->streams[i]); av_freep(&s->streams[i]);
} }
return -1; return -1;
@ -440,7 +440,7 @@ resync:
//av_log(NULL, AV_LOG_DEBUG, "dts:%Ld offset:%d %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, n, size); //av_log(NULL, AV_LOG_DEBUG, "dts:%Ld offset:%d %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, n, size);
pkt->stream_index = avi->stream_index; pkt->stream_index = avi->stream_index;
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->index_entries){ if(st->index_entries){
AVIndexEntry *e; AVIndexEntry *e;
int index; int index;
@ -580,9 +580,9 @@ resync:
g = get_byte(pb); g = get_byte(pb);
b = get_byte(pb); b = get_byte(pb);
get_byte(pb); get_byte(pb);
st->codec.palctrl->palette[k] = b + (g << 8) + (r << 16); st->codec->palctrl->palette[k] = b + (g << 8) + (r << 16);
} }
st->codec.palctrl->palette_changed = 1; st->codec->palctrl->palette_changed = 1;
goto resync; goto resync;
} }
@ -786,8 +786,8 @@ static int avi_read_close(AVFormatContext *s)
AVStream *st = s->streams[i]; AVStream *st = s->streams[i];
AVIStream *ast = st->priv_data; AVIStream *ast = st->priv_data;
av_free(ast); av_free(ast);
av_free(st->codec.extradata); av_free(st->codec->extradata);
av_free(st->codec.palctrl); av_free(st->codec->palctrl);
} }
if (avi->dv_demux) if (avi->dv_demux)

View File

@ -338,7 +338,7 @@ static int avi_write_header(AVFormatContext *s)
video_enc = NULL; video_enc = NULL;
for(n=0;n<s->nb_streams;n++) { for(n=0;n<s->nb_streams;n++) {
stream = &s->streams[n]->codec; stream = s->streams[n]->codec;
bitrate += stream->bit_rate; bitrate += stream->bit_rate;
if (stream->codec_type == CODEC_TYPE_VIDEO) if (stream->codec_type == CODEC_TYPE_VIDEO)
video_enc = stream; video_enc = stream;
@ -376,7 +376,7 @@ static int avi_write_header(AVFormatContext *s)
list2 = start_tag(pb, "LIST"); list2 = start_tag(pb, "LIST");
put_tag(pb, "strl"); put_tag(pb, "strl");
stream = &s->streams[i]->codec; stream = s->streams[i]->codec;
/* FourCC should really be set by the codec itself */ /* FourCC should really be set by the codec itself */
if (! stream->codec_tag) { if (! stream->codec_tag) {
@ -504,7 +504,7 @@ static int avi_write_ix(AVFormatContext *s)
for (i=0;i<s->nb_streams;i++) { for (i=0;i<s->nb_streams;i++) {
offset_t ix, pos; offset_t ix, pos;
avi_stream2fourcc(&tag[0], i, s->streams[i]->codec.codec_type); avi_stream2fourcc(&tag[0], i, s->streams[i]->codec->codec_type);
ix_tag[3] = '0' + i; ix_tag[3] = '0' + i;
/* Writing AVI OpenDML leaf index chunk */ /* Writing AVI OpenDML leaf index chunk */
@ -576,7 +576,7 @@ static int avi_write_idx1(AVFormatContext *s)
} }
if (!empty) { if (!empty) {
avi_stream2fourcc(&tag[0], stream_id, avi_stream2fourcc(&tag[0], stream_id,
s->streams[stream_id]->codec.codec_type); s->streams[stream_id]->codec->codec_type);
put_tag(pb, &tag[0]); put_tag(pb, &tag[0]);
put_le32(pb, ie->flags); put_le32(pb, ie->flags);
put_le32(pb, ie->pos); put_le32(pb, ie->pos);
@ -591,7 +591,7 @@ static int avi_write_idx1(AVFormatContext *s)
nb_frames = 0; nb_frames = 0;
for(n=0;n<s->nb_streams;n++) { for(n=0;n<s->nb_streams;n++) {
if (avi->frames_hdr_strm[n] != 0) { if (avi->frames_hdr_strm[n] != 0) {
stream = &s->streams[n]->codec; stream = s->streams[n]->codec;
url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET); url_fseek(pb, avi->frames_hdr_strm[n], SEEK_SET);
ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
if (au_ssize == 0) { if (au_ssize == 0) {
@ -618,7 +618,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
unsigned char tag[5]; unsigned char tag[5];
unsigned int flags=0; unsigned int flags=0;
const int stream_index= pkt->stream_index; const int stream_index= pkt->stream_index;
AVCodecContext *enc= &s->streams[stream_index]->codec; AVCodecContext *enc= s->streams[stream_index]->codec;
int size= pkt->size; int size= pkt->size;
// av_log(s, AV_LOG_DEBUG, "%lld %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index); // av_log(s, AV_LOG_DEBUG, "%lld %d %d\n", pkt->dts, avi->packet_count[stream_index], stream_index);
@ -705,7 +705,7 @@ static int avi_write_trailer(AVFormatContext *s)
url_fskip(pb, 16); url_fskip(pb, 16);
for (n=nb_frames=0;n<s->nb_streams;n++) { for (n=nb_frames=0;n<s->nb_streams;n++) {
AVCodecContext *stream = &s->streams[n]->codec; AVCodecContext *stream = s->streams[n]->codec;
if (stream->codec_type == CODEC_TYPE_VIDEO) { if (stream->codec_type == CODEC_TYPE_VIDEO) {
if (nb_frames < stream->frame_number) if (nb_frames < stream->frame_number)
nb_frames = stream->frame_number; nb_frames = stream->frame_number;

View File

@ -560,8 +560,8 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame)
if (!c->ast[i]) if (!c->ast[i])
break; break;
av_set_pts_info(c->ast[i], 64, 1, 30000); av_set_pts_info(c->ast[i], 64, 1, 30000);
c->ast[i]->codec.codec_type = CODEC_TYPE_AUDIO; c->ast[i]->codec->codec_type = CODEC_TYPE_AUDIO;
c->ast[i]->codec.codec_id = CODEC_ID_PCM_S16LE; c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE;
av_init_packet(&c->audio_pkt[i]); av_init_packet(&c->audio_pkt[i]);
c->audio_pkt[i].size = 0; c->audio_pkt[i].size = 0;
@ -569,9 +569,9 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame)
c->audio_pkt[i].stream_index = c->ast[i]->index; c->audio_pkt[i].stream_index = c->ast[i]->index;
c->audio_pkt[i].flags |= PKT_FLAG_KEY; c->audio_pkt[i].flags |= PKT_FLAG_KEY;
} }
c->ast[i]->codec.sample_rate = dv_audio_frequency[freq]; c->ast[i]->codec->sample_rate = dv_audio_frequency[freq];
c->ast[i]->codec.channels = 2; c->ast[i]->codec->channels = 2;
c->ast[i]->codec.bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16;
c->ast[i]->start_time = 0; c->ast[i]->start_time = 0;
} }
c->ach = i; c->ach = i;
@ -589,7 +589,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
sys = dv_frame_profile(frame); sys = dv_frame_profile(frame);
if (sys) { if (sys) {
avctx = &c->vst->codec; avctx = c->vst->codec;
av_set_pts_info(c->vst, 64, sys->frame_rate_base, sys->frame_rate); av_set_pts_info(c->vst, 64, sys->frame_rate_base, sys->frame_rate);
avctx->time_base= (AVRational){sys->frame_rate_base, sys->frame_rate}; avctx->time_base= (AVRational){sys->frame_rate_base, sys->frame_rate};
@ -628,10 +628,10 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
c->has_video = 0; c->has_video = 0;
} }
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
/* FIXME: we have to have more sensible approach than this one */ /* FIXME: we have to have more sensible approach than this one */
if (c->has_video) if (c->has_video)
av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames); av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
dv_inject_video(c, data, *frame); dv_inject_video(c, data, *frame);
c->has_video = 1; c->has_video = 1;
@ -642,7 +642,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
reqasize = 4 * dv_audio_frame_size(c->sys, c->frames); reqasize = 4 * dv_audio_frame_size(c->sys, c->frames);
fsize = fifo_size(&c->audio_data, c->audio_data.rptr); fsize = fifo_size(&c->audio_data, c->audio_data.rptr);
if (st->codec.codec_type == CODEC_TYPE_AUDIO || (c->has_video && fsize >= reqasize)) { if (st->codec->codec_type == CODEC_TYPE_AUDIO || (c->has_video && fsize >= reqasize)) {
if (fsize + data_size >= reqasize && !c->has_audio) { if (fsize + data_size >= reqasize && !c->has_audio) {
if (fsize >= reqasize) { if (fsize >= reqasize) {
fifo_read(&c->audio_data, &pcm[0], reqasize, &c->audio_data.rptr); fifo_read(&c->audio_data, &pcm[0], reqasize, &c->audio_data.rptr);
@ -658,7 +658,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
/* FIXME: we have to have more sensible approach than this one */ /* FIXME: we have to have more sensible approach than this one */
if (fifo_size(&c->audio_data, c->audio_data.rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) if (fifo_size(&c->audio_data, c->audio_data.rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames); av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr); fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr);
} }
@ -682,7 +682,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s)
/* We have to sort out where audio and where video stream is */ /* We have to sort out where audio and where video stream is */
for (i=0; i<s->nb_streams; i++) { for (i=0; i<s->nb_streams; i++) {
switch (s->streams[i]->codec.codec_type) { switch (s->streams[i]->codec->codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
vst = s->streams[i]; vst = s->streams[i];
break; break;
@ -695,13 +695,13 @@ DVMuxContext* dv_init_mux(AVFormatContext* s)
} }
/* Some checks -- DV format is very picky about its incoming streams */ /* Some checks -- DV format is very picky about its incoming streams */
if (!vst || vst->codec.codec_id != CODEC_ID_DVVIDEO) if (!vst || vst->codec->codec_id != CODEC_ID_DVVIDEO)
goto bail_out; goto bail_out;
if (ast && (ast->codec.codec_id != CODEC_ID_PCM_S16LE || if (ast && (ast->codec->codec_id != CODEC_ID_PCM_S16LE ||
ast->codec.sample_rate != 48000 || ast->codec->sample_rate != 48000 ||
ast->codec.channels != 2)) ast->codec->channels != 2))
goto bail_out; goto bail_out;
c->sys = dv_codec_profile(&vst->codec); c->sys = dv_codec_profile(vst->codec);
if (!c->sys) if (!c->sys)
goto bail_out; goto bail_out;
@ -711,7 +711,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s)
c->has_video = 0; c->has_video = 0;
c->start_time = (time_t)s->timestamp; c->start_time = (time_t)s->timestamp;
c->aspect = 0; /* 4:3 is the default */ c->aspect = 0; /* 4:3 is the default */
if ((int)(av_q2d(vst->codec.sample_aspect_ratio) * vst->codec.width / vst->codec.height * 10) == 17) /* 16:9 */ if ((int)(av_q2d(vst->codec->sample_aspect_ratio) * vst->codec->width / vst->codec->height * 10) == 17) /* 16:9 */
c->aspect = 0x07; c->aspect = 0x07;
if (ast && fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) if (ast && fifo_init(&c->audio_data, 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0)
@ -751,9 +751,9 @@ DVDemuxContext* dv_init_demux(AVFormatContext *s)
c->frames = 0; c->frames = 0;
c->abytes = 0; c->abytes = 0;
c->vst->codec.codec_type = CODEC_TYPE_VIDEO; c->vst->codec->codec_type = CODEC_TYPE_VIDEO;
c->vst->codec.codec_id = CODEC_ID_DVVIDEO; c->vst->codec->codec_id = CODEC_ID_DVVIDEO;
c->vst->codec.bit_rate = 25000000; c->vst->codec->bit_rate = 25000000;
c->vst->start_time = 0; c->vst->start_time = 0;
return c; return c;
@ -790,7 +790,7 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt,
size = dv_extract_audio_info(c, buf); size = dv_extract_audio_info(c, buf);
for (i=0; i<c->ach; i++) { for (i=0; i<c->ach; i++) {
c->audio_pkt[i].size = size; c->audio_pkt[i].size = size;
c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec.bit_rate; c->audio_pkt[i].pts = c->abytes * 30000*8 / c->ast[i]->codec->bit_rate;
} }
dv_extract_audio(buf, c->audio_buf[0], c->audio_buf[1]); dv_extract_audio(buf, c->audio_buf[0], c->audio_buf[1]);
c->abytes += size; c->abytes += size;
@ -813,7 +813,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c,
int64_t timestamp, int flags) int64_t timestamp, int flags)
{ {
// FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk)
const DVprofile* sys = dv_codec_profile(&c->vst->codec); const DVprofile* sys = dv_codec_profile(c->vst->codec);
int64_t offset; int64_t offset;
int64_t size = url_fsize(&s->pb); int64_t size = url_fsize(&s->pb);
int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size;
@ -886,12 +886,12 @@ static int dv_read_seek(AVFormatContext *s, int stream_index,
RawDVContext *r = s->priv_data; RawDVContext *r = s->priv_data;
DVDemuxContext *c = r->dv_demux; DVDemuxContext *c = r->dv_demux;
int64_t offset= dv_frame_offset(s, c, timestamp, flags); int64_t offset= dv_frame_offset(s, c, timestamp, flags);
const DVprofile* sys = dv_codec_profile(&c->vst->codec); const DVprofile* sys = dv_codec_profile(c->vst->codec);
c->frames= offset / sys->frame_size; c->frames= offset / sys->frame_size;
if (c->ach) if (c->ach)
c->abytes= av_rescale(c->frames, c->abytes= av_rescale(c->frames,
c->ast[0]->codec.bit_rate * (int64_t)sys->frame_rate_base, c->ast[0]->codec->bit_rate * (int64_t)sys->frame_rate_base,
8*sys->frame_rate); 8*sys->frame_rate);
dv_flush_audio_packets(c); dv_flush_audio_packets(c);

View File

@ -188,9 +188,9 @@ static int ea_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
ea->video_stream_index = st->index; ea->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_EA_MJPEG; st->codec->codec_id = CODEC_ID_EA_MJPEG;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
#endif #endif
/* initialize the audio decoder stream */ /* initialize the audio decoder stream */
@ -198,15 +198,15 @@ static int ea_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, EA_SAMPLE_RATE); av_set_pts_info(st, 33, 1, EA_SAMPLE_RATE);
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_ADPCM_EA; st->codec->codec_id = CODEC_ID_ADPCM_EA;
st->codec.codec_tag = 0; /* no tag */ st->codec->codec_tag = 0; /* no tag */
st->codec.channels = ea->num_channels; st->codec->channels = ea->num_channels;
st->codec.sample_rate = EA_SAMPLE_RATE; st->codec->sample_rate = EA_SAMPLE_RATE;
st->codec.bits_per_sample = EA_BITS_PER_SAMPLE; st->codec->bits_per_sample = EA_BITS_PER_SAMPLE;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample / 4; st->codec->bits_per_sample / 4;
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
ea->audio_stream_index = st->index; ea->audio_stream_index = st->index;
ea->audio_frame_counter = 0; ea->audio_frame_counter = 0;

View File

@ -141,7 +141,7 @@ static int ffm_write_header(AVFormatContext *s)
bit_rate = 0; bit_rate = 0;
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
st = s->streams[i]; st = s->streams[i];
bit_rate += st->codec.bit_rate; bit_rate += st->codec->bit_rate;
} }
put_be32(pb, bit_rate); put_be32(pb, bit_rate);
@ -154,7 +154,7 @@ static int ffm_write_header(AVFormatContext *s)
av_set_pts_info(st, 64, 1, 1000000); av_set_pts_info(st, 64, 1, 1000000);
st->priv_data = fst; st->priv_data = fst;
codec = &st->codec; codec = st->codec;
/* generic info */ /* generic info */
put_be32(pb, codec->codec_id); put_be32(pb, codec->codec_id);
put_byte(pb, codec->codec_type); put_byte(pb, codec->codec_type);
@ -247,10 +247,10 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt)
int size= pkt->size; int size= pkt->size;
//XXX/FIXME use duration from pkt //XXX/FIXME use duration from pkt
if (st->codec.codec_type == CODEC_TYPE_AUDIO) { if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); duration = ((float)st->codec->frame_size / st->codec->sample_rate * 1000000.0);
} else { } else {
duration = (1000000.0 * st->codec.time_base.num / (float)st->codec.time_base.den); duration = (1000000.0 * st->codec->time_base.num / (float)st->codec->time_base.den);
} }
pts = fst->pts; pts = fst->pts;
@ -485,10 +485,10 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->priv_data = fst; st->priv_data = fst;
codec = &st->codec; codec = st->codec;
/* generic info */ /* generic info */
st->codec.codec_id = get_be32(pb); st->codec->codec_id = get_be32(pb);
st->codec.codec_type = get_byte(pb); /* codec_type */ st->codec->codec_type = get_byte(pb); /* codec_type */
codec->bit_rate = get_be32(pb); codec->bit_rate = get_be32(pb);
st->quality = get_be32(pb); st->quality = get_be32(pb);
codec->flags = get_be32(pb); codec->flags = get_be32(pb);

View File

@ -86,19 +86,19 @@ static int flic_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
flic->video_stream_index = st->index; flic->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_FLIC; st->codec->codec_id = CODEC_ID_FLIC;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = LE_16(&header[0x08]); st->codec->width = LE_16(&header[0x08]);
st->codec.height = LE_16(&header[0x0A]); st->codec->height = LE_16(&header[0x0A]);
if (!st->codec.width || !st->codec.height) if (!st->codec->width || !st->codec->height)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
/* send over the whole 128-byte FLIC header */ /* send over the whole 128-byte FLIC header */
st->codec.extradata_size = FLIC_HEADER_SIZE; st->codec->extradata_size = FLIC_HEADER_SIZE;
st->codec.extradata = av_malloc(FLIC_HEADER_SIZE); st->codec->extradata = av_malloc(FLIC_HEADER_SIZE);
memcpy(st->codec.extradata, header, FLIC_HEADER_SIZE); memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE);
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
@ -113,10 +113,10 @@ static int flic_read_header(AVFormatContext *s,
url_fseek(pb, 12, SEEK_SET); url_fseek(pb, 12, SEEK_SET);
/* send over abbreviated FLIC header chunk */ /* send over abbreviated FLIC header chunk */
av_free(st->codec.extradata); av_free(st->codec->extradata);
st->codec.extradata_size = 12; st->codec->extradata_size = 12;
st->codec.extradata = av_malloc(12); st->codec->extradata = av_malloc(12);
memcpy(st->codec.extradata, header, 12); memcpy(st->codec->extradata, header, 12);
} else if (magic_number == FLIC_FILE_MAGIC_1) { } else if (magic_number == FLIC_FILE_MAGIC_1) {
/* /*

View File

@ -102,7 +102,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
st->codec.time_base= (AVRational){1,1000}; st->codec->time_base= (AVRational){1,1000};
} }
// av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard); // av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard);
if( (st->discard >= AVDISCARD_NONKEY && !((flags >> 4)==1 || is_audio)) if( (st->discard >= AVDISCARD_NONKEY && !((flags >> 4)==1 || is_audio))
@ -116,34 +116,34 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
if(is_audio){ if(is_audio){
if(st->codec.sample_rate == 0){ if(st->codec->sample_rate == 0){
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.channels = (flags&1)+1; st->codec->channels = (flags&1)+1;
if((flags >> 4) == 5) if((flags >> 4) == 5)
st->codec.sample_rate= 8000; st->codec->sample_rate= 8000;
else else
st->codec.sample_rate = (44100<<((flags>>2)&3))>>3; st->codec->sample_rate = (44100<<((flags>>2)&3))>>3;
switch(flags >> 4){/* 0: uncompressed 1: ADPCM 2: mp3 5: Nellymoser 8kHz mono 6: Nellymoser*/ switch(flags >> 4){/* 0: uncompressed 1: ADPCM 2: mp3 5: Nellymoser 8kHz mono 6: Nellymoser*/
case 0: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16BE; case 0: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16BE;
else st->codec.codec_id = CODEC_ID_PCM_S8; break; else st->codec->codec_id = CODEC_ID_PCM_S8; break;
case 1: st->codec.codec_id = CODEC_ID_ADPCM_SWF; break; case 1: st->codec->codec_id = CODEC_ID_ADPCM_SWF; break;
case 2: st->codec.codec_id = CODEC_ID_MP3; break; case 2: st->codec->codec_id = CODEC_ID_MP3; break;
// this is not listed at FLV but at SWF, strange... // this is not listed at FLV but at SWF, strange...
case 3: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16LE; case 3: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16LE;
else st->codec.codec_id = CODEC_ID_PCM_S8; break; else st->codec->codec_id = CODEC_ID_PCM_S8; break;
default: default:
av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n", flags >> 4); av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n", flags >> 4);
st->codec.codec_tag= (flags >> 4); st->codec->codec_tag= (flags >> 4);
} }
st->codec.bits_per_sample = (flags & 2) ? 16 : 8; st->codec->bits_per_sample = (flags & 2) ? 16 : 8;
} }
}else{ }else{
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
switch(flags & 0xF){ switch(flags & 0xF){
case 2: st->codec.codec_id = CODEC_ID_FLV1; break; case 2: st->codec->codec_id = CODEC_ID_FLV1; break;
default: default:
av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flags & 0xf); av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flags & 0xf);
st->codec.codec_tag= flags & 0xF; st->codec->codec_tag= flags & 0xF;
} }
} }

View File

@ -97,7 +97,7 @@ static int flv_write_header(AVFormatContext *s)
put_be32(pb,0); put_be32(pb,0);
for(i=0; i<s->nb_streams; i++){ for(i=0; i<s->nb_streams; i++){
AVCodecContext *enc = &s->streams[i]->codec; AVCodecContext *enc = s->streams[i]->codec;
av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */ av_set_pts_info(s->streams[i], 24, 1, 1000); /* 24 bit pts in ms */
if(enc->codec_tag == 5){ if(enc->codec_tag == 5){
put_byte(pb,8); // message type put_byte(pb,8); // message type
@ -134,7 +134,7 @@ static int flv_write_trailer(AVFormatContext *s)
static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) static int flv_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
ByteIOContext *pb = &s->pb; ByteIOContext *pb = &s->pb;
AVCodecContext *enc = &s->streams[pkt->stream_index]->codec; AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
FLVContext *flv = s->priv_data; FLVContext *flv = s->priv_data;
int size= pkt->size; int size= pkt->size;
int flags; int flags;

View File

@ -327,7 +327,7 @@ static int gif_write_header(AVFormatContext *s)
video_enc = NULL; video_enc = NULL;
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
enc = &s->streams[i]->codec; enc = s->streams[i]->codec;
if (enc->codec_type != CODEC_TYPE_AUDIO) if (enc->codec_type != CODEC_TYPE_AUDIO)
video_enc = enc; video_enc = enc;
} }
@ -388,7 +388,7 @@ static int gif_write_video(AVFormatContext *s,
static int gif_write_packet(AVFormatContext *s, AVPacket *pkt) static int gif_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
AVCodecContext *codec = &s->streams[pkt->stream_index]->codec; AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
if (codec->codec_type == CODEC_TYPE_AUDIO) if (codec->codec_type == CODEC_TYPE_AUDIO)
return 0; /* just ignore audio */ return 0; /* just ignore audio */
else else

View File

@ -555,14 +555,14 @@ static int gif_read_header(AVFormatContext * s1,
if (!st) if (!st)
return -1; return -1;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_RAWVIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec.time_base.den = 5; st->codec->time_base.den = 5;
st->codec.time_base.num = 1; st->codec->time_base.num = 1;
/* XXX: check if screen size is always valid */ /* XXX: check if screen size is always valid */
st->codec.width = s->screen_width; st->codec->width = s->screen_width;
st->codec.height = s->screen_height; st->codec->height = s->screen_height;
st->codec.pix_fmt = PIX_FMT_RGB24; st->codec->pix_fmt = PIX_FMT_RGB24;
return 0; return 0;
} }

View File

@ -109,11 +109,11 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
} }
desired_palette = -1; desired_palette = -1;
if (st->codec.pix_fmt == PIX_FMT_YUV420P) { if (st->codec->pix_fmt == PIX_FMT_YUV420P) {
desired_palette = VIDEO_PALETTE_YUV420P; desired_palette = VIDEO_PALETTE_YUV420P;
} else if (st->codec.pix_fmt == PIX_FMT_YUV422) { } else if (st->codec->pix_fmt == PIX_FMT_YUV422) {
desired_palette = VIDEO_PALETTE_YUV422; desired_palette = VIDEO_PALETTE_YUV422;
} else if (st->codec.pix_fmt == PIX_FMT_BGR24) { } else if (st->codec->pix_fmt == PIX_FMT_BGR24) {
desired_palette = VIDEO_PALETTE_RGB24; desired_palette = VIDEO_PALETTE_RGB24;
} }
@ -245,15 +245,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
switch(s->frame_format) { switch(s->frame_format) {
case VIDEO_PALETTE_YUV420P: case VIDEO_PALETTE_YUV420P:
frame_size = (width * height * 3) / 2; frame_size = (width * height * 3) / 2;
st->codec.pix_fmt = PIX_FMT_YUV420P; st->codec->pix_fmt = PIX_FMT_YUV420P;
break; break;
case VIDEO_PALETTE_YUV422: case VIDEO_PALETTE_YUV422:
frame_size = width * height * 2; frame_size = width * height * 2;
st->codec.pix_fmt = PIX_FMT_YUV422; st->codec->pix_fmt = PIX_FMT_YUV422;
break; break;
case VIDEO_PALETTE_RGB24: case VIDEO_PALETTE_RGB24:
frame_size = width * height * 3; frame_size = width * height * 3;
st->codec.pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */ st->codec->pix_fmt = PIX_FMT_BGR24; /* NOTE: v4l uses BGR24, not RGB24 ! */
break; break;
default: default:
goto fail; goto fail;
@ -261,12 +261,12 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->fd = video_fd; s->fd = video_fd;
s->frame_size = frame_size; s->frame_size = frame_size;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_RAWVIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec.width = width; st->codec->width = width;
st->codec.height = height; st->codec->height = height;
st->codec.time_base.den = frame_rate; st->codec->time_base.den = frame_rate;
st->codec.time_base.num = frame_rate_base; st->codec->time_base.num = frame_rate_base;
return 0; return 0;
fail: fail:

View File

@ -156,20 +156,20 @@ static int idcin_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
idcin->video_stream_index = st->index; idcin->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_IDCIN; st->codec->codec_id = CODEC_ID_IDCIN;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = width; st->codec->width = width;
st->codec.height = height; st->codec->height = height;
/* load up the Huffman tables into extradata */ /* load up the Huffman tables into extradata */
st->codec.extradata_size = HUFFMAN_TABLE_SIZE; st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
st->codec.extradata = av_malloc(HUFFMAN_TABLE_SIZE); st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
if (get_buffer(pb, st->codec.extradata, HUFFMAN_TABLE_SIZE) != if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
HUFFMAN_TABLE_SIZE) HUFFMAN_TABLE_SIZE)
return AVERROR_IO; return AVERROR_IO;
/* save a reference in order to transport the palette */ /* save a reference in order to transport the palette */
st->codec.palctrl = &idcin->palctrl; st->codec->palctrl = &idcin->palctrl;
/* if sample rate is 0, assume no audio */ /* if sample rate is 0, assume no audio */
if (sample_rate) { if (sample_rate) {
@ -179,17 +179,17 @@ static int idcin_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
idcin->audio_stream_index = st->index; idcin->audio_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = 1; st->codec->codec_tag = 1;
st->codec.channels = channels; st->codec->channels = channels;
st->codec.sample_rate = sample_rate; st->codec->sample_rate = sample_rate;
st->codec.bits_per_sample = bytes_per_sample * 8; st->codec->bits_per_sample = bytes_per_sample * 8;
st->codec.bit_rate = sample_rate * bytes_per_sample * 8 * channels; st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
st->codec.block_align = bytes_per_sample * channels; st->codec->block_align = bytes_per_sample * channels;
if (bytes_per_sample == 1) if (bytes_per_sample == 1)
st->codec.codec_id = CODEC_ID_PCM_U8; st->codec->codec_id = CODEC_ID_PCM_U8;
else else
st->codec.codec_id = CODEC_ID_PCM_S16LE; st->codec->codec_id = CODEC_ID_PCM_S16LE;
if (sample_rate % 14 != 0) { if (sample_rate % 14 != 0) {
idcin->audio_chunk_size1 = (sample_rate / 14) * idcin->audio_chunk_size1 = (sample_rate / 14) *

View File

@ -145,11 +145,11 @@ static int roq_read_header(AVFormatContext *s,
/* set the pts reference (1 pts = 1/90000) */ /* set the pts reference (1 pts = 1/90000) */
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
roq->video_stream_index = st->index; roq->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_ROQ; st->codec->codec_id = CODEC_ID_ROQ;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = roq->width; st->codec->width = roq->width;
st->codec.height = roq->height; st->codec->height = roq->height;
if (roq->audio_channels) { if (roq->audio_channels) {
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
@ -157,15 +157,15 @@ static int roq_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
roq->audio_stream_index = st->index; roq->audio_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_ROQ_DPCM; st->codec->codec_id = CODEC_ID_ROQ_DPCM;
st->codec.codec_tag = 0; /* no tag */ st->codec->codec_tag = 0; /* no tag */
st->codec.channels = roq->audio_channels; st->codec->channels = roq->audio_channels;
st->codec.sample_rate = RoQ_AUDIO_SAMPLE_RATE; st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE;
st->codec.bits_per_sample = 16; st->codec->bits_per_sample = 16;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample; st->codec->bits_per_sample;
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
} }
return 0; return 0;

View File

@ -134,9 +134,9 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
s->is_pipe = 1; s->is_pipe = 1;
if (!ap || !ap->time_base.num) { if (!ap || !ap->time_base.num) {
st->codec.time_base= (AVRational){1,25}; st->codec->time_base= (AVRational){1,25};
} else { } else {
st->codec.time_base= ap->time_base; st->codec->time_base= ap->time_base;
} }
if (!s->is_pipe) { if (!s->is_pipe) {
@ -166,11 +166,11 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
url_fseek(f, 0, SEEK_SET); url_fseek(f, 0, SEEK_SET);
} }
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_RAWVIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec.width = s->width; st->codec->width = s->width;
st->codec.height = s->height; st->codec->height = s->height;
st->codec.pix_fmt = s->pix_fmt; st->codec->pix_fmt = s->pix_fmt;
s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15)); s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15));
return 0; return 0;
@ -232,7 +232,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
} else { } else {
/* XXX: computing this pts is not necessary as it is done in /* XXX: computing this pts is not necessary as it is done in
the generic code too */ the generic code too */
pkt->pts = av_rescale((int64_t)s->img_count * s1->streams[0]->codec.time_base.num, s1->streams[0]->time_base.den, s1->streams[0]->codec.time_base.den) / s1->streams[0]->time_base.num; pkt->pts = av_rescale((int64_t)s->img_count * s1->streams[0]->codec->time_base.num, s1->streams[0]->time_base.den, s1->streams[0]->codec->time_base.den) / s1->streams[0]->time_base.num;
s->img_count++; s->img_count++;
s->img_number++; s->img_number++;
return 0; return 0;
@ -276,7 +276,7 @@ static int img_set_parameters(AVFormatContext *s, AVFormatParameters *ap)
return -1; return -1;
img->img_fmt = img_fmt; img->img_fmt = img_fmt;
img->pix_fmt = i; img->pix_fmt = i;
st->codec.pix_fmt = img->pix_fmt; st->codec->pix_fmt = img->pix_fmt;
return 0; return 0;
} }
@ -306,8 +306,8 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
char filename[1024]; char filename[1024];
AVImageInfo info; AVImageInfo info;
width = st->codec.width; width = st->codec->width;
height = st->codec.height; height = st->codec->height;
picture = (AVPicture *)pkt->data; picture = (AVPicture *)pkt->data;
@ -323,7 +323,7 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
} }
info.width = width; info.width = width;
info.height = height; info.height = height;
info.pix_fmt = st->codec.pix_fmt; info.pix_fmt = st->codec->pix_fmt;
info.interleaved = 0; /* FIXME: there should be a way to set it right */ info.interleaved = 0; /* FIXME: there should be a way to set it right */
info.pict = *picture; info.pict = *picture;
ret = av_write_image(pb, img->img_fmt, &info); ret = av_write_image(pb, img->img_fmt, &info);

View File

@ -193,8 +193,8 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
} }
if(ap && ap->width && ap->height){ if(ap && ap->width && ap->height){
st->codec.width = ap->width; st->codec->width = ap->width;
st->codec.height= ap->height; st->codec->height= ap->height;
} }
if (!s->is_pipe) { if (!s->is_pipe) {
@ -209,17 +209,17 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap)
} }
if(ap->video_codec_id){ if(ap->video_codec_id){
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = ap->video_codec_id; st->codec->codec_id = ap->video_codec_id;
}else if(ap->audio_codec_id){ }else if(ap->audio_codec_id){
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = ap->audio_codec_id; st->codec->codec_id = ap->audio_codec_id;
}else{ }else{
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = av_str2id(img_tags, s->path); st->codec->codec_id = av_str2id(img_tags, s->path);
} }
if(st->codec.codec_type == CODEC_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE) if(st->codec->codec_type == CODEC_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE)
st->codec.pix_fmt = ap->pix_fmt; st->codec->pix_fmt = ap->pix_fmt;
return 0; return 0;
} }
@ -231,7 +231,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
int i; int i;
int size[3]={0}, ret[3]={0}; int size[3]={0}, ret[3]={0};
ByteIOContext f1[3], *f[3]= {&f1[0], &f1[1], &f1[2]}; ByteIOContext f1[3], *f[3]= {&f1[0], &f1[1], &f1[2]};
AVCodecContext *codec= &s1->streams[0]->codec; AVCodecContext *codec= s1->streams[0]->codec;
if (!s->is_pipe) { if (!s->is_pipe) {
/* loop over input */ /* loop over input */
@ -314,7 +314,7 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt)
VideoData *img = s->priv_data; VideoData *img = s->priv_data;
ByteIOContext pb1[3], *pb[3]= {&pb1[0], &pb1[1], &pb1[2]}; ByteIOContext pb1[3], *pb[3]= {&pb1[0], &pb1[1], &pb1[2]};
char filename[1024]; char filename[1024];
AVCodecContext *codec= &s->streams[ pkt->stream_index ]->codec; AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec;
int i; int i;
if (!img->is_pipe) { if (!img->is_pipe) {

View File

@ -554,14 +554,14 @@ static int ipmovie_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
ipmovie->video_stream_index = st->index; ipmovie->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_INTERPLAY_VIDEO; st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = ipmovie->video_width; st->codec->width = ipmovie->video_width;
st->codec.height = ipmovie->video_height; st->codec->height = ipmovie->video_height;
/* palette considerations */ /* palette considerations */
st->codec.palctrl = &ipmovie->palette_control; st->codec->palctrl = &ipmovie->palette_control;
if (ipmovie->audio_type) { if (ipmovie->audio_type) {
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
@ -569,17 +569,17 @@ static int ipmovie_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
ipmovie->audio_stream_index = st->index; ipmovie->audio_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = ipmovie->audio_type; st->codec->codec_id = ipmovie->audio_type;
st->codec.codec_tag = 0; /* no tag */ st->codec->codec_tag = 0; /* no tag */
st->codec.channels = ipmovie->audio_channels; st->codec->channels = ipmovie->audio_channels;
st->codec.sample_rate = ipmovie->audio_sample_rate; st->codec->sample_rate = ipmovie->audio_sample_rate;
st->codec.bits_per_sample = ipmovie->audio_bits; st->codec->bits_per_sample = ipmovie->audio_bits;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample; st->codec->bits_per_sample;
if (st->codec.codec_id == CODEC_ID_INTERPLAY_DPCM) if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
st->codec.bit_rate /= 2; st->codec->bit_rate /= 2;
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
} }
return 0; return 0;

View File

@ -2273,46 +2273,46 @@ matroska_read_header (AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */
st->codec.codec_id = codec_id; st->codec->codec_id = codec_id;
if(extradata){ if(extradata){
st->codec.extradata = extradata; st->codec->extradata = extradata;
st->codec.extradata_size = extradata_size; st->codec->extradata_size = extradata_size;
} else if(track->codec_priv && track->codec_priv_size > 0){ } else if(track->codec_priv && track->codec_priv_size > 0){
st->codec.extradata = av_malloc(track->codec_priv_size); st->codec->extradata = av_malloc(track->codec_priv_size);
if(st->codec.extradata == NULL) if(st->codec->extradata == NULL)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.extradata_size = track->codec_priv_size; st->codec->extradata_size = track->codec_priv_size;
memcpy(st->codec.extradata, track->codec_priv, memcpy(st->codec->extradata, track->codec_priv,
track->codec_priv_size); track->codec_priv_size);
} }
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track; MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_tag = videotrack->fourcc; st->codec->codec_tag = videotrack->fourcc;
st->codec.width = videotrack->pixel_width; st->codec->width = videotrack->pixel_width;
st->codec.height = videotrack->pixel_height; st->codec->height = videotrack->pixel_height;
if (videotrack->display_width == 0) if (videotrack->display_width == 0)
st->codec.sample_aspect_ratio.num = st->codec->sample_aspect_ratio.num =
videotrack->pixel_width; videotrack->pixel_width;
else else
st->codec.sample_aspect_ratio.num = st->codec->sample_aspect_ratio.num =
videotrack->display_width; videotrack->display_width;
if (videotrack->display_height == 0) if (videotrack->display_height == 0)
st->codec.sample_aspect_ratio.num = st->codec->sample_aspect_ratio.num =
videotrack->pixel_height; videotrack->pixel_height;
else else
st->codec.sample_aspect_ratio.num = st->codec->sample_aspect_ratio.num =
videotrack->display_height; videotrack->display_height;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track; MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.sample_rate = audiotrack->samplerate; st->codec->sample_rate = audiotrack->samplerate;
st->codec.channels = audiotrack->channels; st->codec->channels = audiotrack->channels;
} }
/* What do we do with private data? E.g. for Vorbis. */ /* What do we do with private data? E.g. for Vorbis. */
@ -2700,7 +2700,7 @@ matroska_read_close (AVFormatContext *s)
} }
for (n = 0; n < s->nb_streams; n++) { for (n = 0; n < s->nb_streams; n++) {
av_free(s->streams[n]->codec.extradata); av_free(s->streams[n]->codec->extradata);
} }
memset(matroska, 0, sizeof(MatroskaDemuxContext)); memset(matroska, 0, sizeof(MatroskaDemuxContext));

View File

@ -61,9 +61,9 @@ static int mmf_write_header(AVFormatContext *s)
offset_t pos; offset_t pos;
int rate; int rate;
rate = mmf_rate_code(s->streams[0]->codec.sample_rate); rate = mmf_rate_code(s->streams[0]->codec->sample_rate);
if(rate < 0) { if(rate < 0) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d\n", s->streams[0]->codec.sample_rate); av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d\n", s->streams[0]->codec->sample_rate);
return -1; return -1;
} }
@ -96,7 +96,7 @@ static int mmf_write_header(AVFormatContext *s)
mmf->awapos = start_tag(pb, "Awa\x01"); mmf->awapos = start_tag(pb, "Awa\x01");
av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec.sample_rate); av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
put_flush_packet(pb); put_flush_packet(pb);
@ -144,7 +144,7 @@ static int mmf_write_trailer(AVFormatContext *s)
/* "play wav" */ /* "play wav" */
put_byte(pb, 0); /* start time */ put_byte(pb, 0); /* start time */
put_byte(pb, 1); /* (channel << 6) | wavenum */ put_byte(pb, 1); /* (channel << 6) | wavenum */
gatetime = size * 500 / s->streams[0]->codec.sample_rate; gatetime = size * 500 / s->streams[0]->codec->sample_rate;
put_varlength(pb, gatetime); /* duration */ put_varlength(pb, gatetime); /* duration */
/* "nop" */ /* "nop" */
@ -239,14 +239,14 @@ static int mmf_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_ADPCM_YAMAHA; st->codec->codec_id = CODEC_ID_ADPCM_YAMAHA;
st->codec.sample_rate = rate; st->codec->sample_rate = rate;
st->codec.channels = 1; st->codec->channels = 1;
st->codec.bits_per_sample = 4; st->codec->bits_per_sample = 4;
st->codec.bit_rate = st->codec.sample_rate * st->codec.bits_per_sample; st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_sample;
av_set_pts_info(st, 64, 1, st->codec.sample_rate); av_set_pts_info(st, 64, 1, st->codec->sample_rate);
return 0; return 0;
} }

View File

@ -481,16 +481,16 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
/* helps parsing the string hereafter... */ /* helps parsing the string hereafter... */
c->mp4 = 0; c->mp4 = 0;
if(type == MKTAG('v', 'i', 'd', 'e')) if(type == MKTAG('v', 'i', 'd', 'e'))
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
else if(type == MKTAG('s', 'o', 'u', 'n')) else if(type == MKTAG('s', 'o', 'u', 'n'))
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
} else if(ctype == 0) { /* MP4 */ } else if(ctype == 0) { /* MP4 */
/* helps parsing the string hereafter... */ /* helps parsing the string hereafter... */
c->mp4 = 1; c->mp4 = 1;
if(type == MKTAG('v', 'i', 'd', 'e')) if(type == MKTAG('v', 'i', 'd', 'e'))
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
else if(type == MKTAG('s', 'o', 'u', 'n')) else if(type == MKTAG('s', 'o', 'u', 'n'))
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
} }
get_be32(pb); /* component manufacture */ get_be32(pb); /* component manufacture */
get_be32(pb); /* component flags */ get_be32(pb); /* component flags */
@ -591,10 +591,10 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
#ifdef DEBUG #ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len); av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len);
#endif #endif
st->codec.extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec.extradata) { if (st->codec->extradata) {
get_buffer(pb, st->codec.extradata, len); get_buffer(pb, st->codec->extradata, len);
st->codec.extradata_size = len; st->codec->extradata_size = len;
} }
} }
} }
@ -703,14 +703,14 @@ static int mov_read_smi(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
// currently SVQ3 decoder expect full STSD header - so let's fake it // currently SVQ3 decoder expect full STSD header - so let's fake it
// this should be fixed and just SMI header should be passed // this should be fixed and just SMI header should be passed
av_free(st->codec.extradata); av_free(st->codec->extradata);
st->codec.extradata_size = 0x5a + atom.size; st->codec->extradata_size = 0x5a + atom.size;
st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec.extradata) { if (st->codec->extradata) {
strcpy(st->codec.extradata, "SVQ3"); // fake strcpy(st->codec->extradata, "SVQ3"); // fake
get_buffer(pb, st->codec.extradata + 0x5a, atom.size); get_buffer(pb, st->codec->extradata + 0x5a, atom.size);
//av_log(NULL, AV_LOG_DEBUG, "Reading SMI %Ld %s\n", atom.size, (char*)st->codec.extradata + 0x5a); //av_log(NULL, AV_LOG_DEBUG, "Reading SMI %Ld %s\n", atom.size, (char*)st->codec->extradata + 0x5a);
} else } else
url_fskip(pb, atom.size); url_fskip(pb, atom.size);
@ -724,13 +724,13 @@ static int mov_read_avcC(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
if((uint64_t)atom.size > (1<<30)) if((uint64_t)atom.size > (1<<30))
return -1; return -1;
av_free(st->codec.extradata); av_free(st->codec->extradata);
st->codec.extradata_size = atom.size; st->codec->extradata_size = atom.size;
st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (st->codec.extradata) { if (st->codec->extradata) {
get_buffer(pb, st->codec.extradata, atom.size); get_buffer(pb, st->codec->extradata, atom.size);
} else } else
url_fskip(pb, atom.size); url_fskip(pb, atom.size);
@ -829,7 +829,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
AVCodec *codec; AVCodec *codec;
codec = avcodec_find_decoder(id); codec = avcodec_find_decoder(id);
if (codec) if (codec)
st->codec.codec_type = codec->type; st->codec->codec_type = codec->type;
} }
#ifdef DEBUG #ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "size=%d 4CC= %c%c%c%c codec_type=%d\n", av_log(NULL, AV_LOG_DEBUG, "size=%d 4CC= %c%c%c%c codec_type=%d\n",
@ -838,23 +838,23 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
(format >> 8) & 0xff, (format >> 8) & 0xff,
(format >> 16) & 0xff, (format >> 16) & 0xff,
(format >> 24) & 0xff, (format >> 24) & 0xff,
st->codec.codec_type); st->codec->codec_type);
#endif #endif
st->codec.codec_tag = format; st->codec->codec_tag = format;
if(st->codec.codec_type==CODEC_TYPE_VIDEO) { if(st->codec->codec_type==CODEC_TYPE_VIDEO) {
MOV_atom_t a = { 0, 0, 0 }; MOV_atom_t a = { 0, 0, 0 };
st->codec.codec_id = id; st->codec->codec_id = id;
get_be16(pb); /* version */ get_be16(pb); /* version */
get_be16(pb); /* revision level */ get_be16(pb); /* revision level */
get_be32(pb); /* vendor */ get_be32(pb); /* vendor */
get_be32(pb); /* temporal quality */ get_be32(pb); /* temporal quality */
get_be32(pb); /* spacial quality */ get_be32(pb); /* spacial quality */
if(st->codec.codec_id == CODEC_ID_MPEG4){ //FIXME this is silly if(st->codec->codec_id == CODEC_ID_MPEG4){ //FIXME this is silly
get_be16(pb); get_be16(pb);
get_be16(pb); get_be16(pb);
}else{ }else{
st->codec.width = get_be16(pb); /* width */ st->codec->width = get_be16(pb); /* width */
st->codec.height = get_be16(pb); /* height */ st->codec->height = get_be16(pb); /* height */
} }
get_be32(pb); /* horiz resolution */ get_be32(pb); /* horiz resolution */
get_be32(pb); /* vert resolution */ get_be32(pb); /* vert resolution */
@ -865,16 +865,16 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
#endif #endif
get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */ get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */
if (codec_name[0] <= 31) { if (codec_name[0] <= 31) {
memcpy(st->codec.codec_name, &codec_name[1],codec_name[0]); memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]);
st->codec.codec_name[codec_name[0]] = 0; st->codec->codec_name[codec_name[0]] = 0;
} }
st->codec.bits_per_sample = get_be16(pb); /* depth */ st->codec->bits_per_sample = get_be16(pb); /* depth */
st->codec.color_table_id = get_be16(pb); /* colortable id */ st->codec->color_table_id = get_be16(pb); /* colortable id */
/* These are set in mov_read_stts and might already be set! /* These are set in mov_read_stts and might already be set!
st->codec.time_base.den = 25; st->codec->time_base.den = 25;
st->codec.time_base.num = 1; st->codec->time_base.num = 1;
*/ */
size -= (16+8*4+2+32+2*2); size -= (16+8*4+2+32+2*2);
#if 0 #if 0
@ -948,8 +948,8 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
#else #else
/* figure out the palette situation */ /* figure out the palette situation */
color_depth = st->codec.bits_per_sample & 0x1F; color_depth = st->codec->bits_per_sample & 0x1F;
color_greyscale = st->codec.bits_per_sample & 0x20; color_greyscale = st->codec->bits_per_sample & 0x20;
/* if the depth is 2, 4, or 8 bpp, file is palettized */ /* if the depth is 2, 4, or 8 bpp, file is palettized */
if ((color_depth == 2) || (color_depth == 4) || if ((color_depth == 2) || (color_depth == 4) ||
@ -970,7 +970,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
color_index = 0; color_index = 0;
} }
} else if (st->codec.color_table_id & 0x08) { } else if (st->codec->color_table_id & 0x08) {
/* if flag bit 3 is set, use the default palette */ /* if flag bit 3 is set, use the default palette */
color_count = 1 << color_depth; color_count = 1 << color_depth;
@ -1012,17 +1012,17 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
} }
} }
st->codec.palctrl = &c->palette_control; st->codec->palctrl = &c->palette_control;
st->codec.palctrl->palette_changed = 1; st->codec->palctrl->palette_changed = 1;
} else } else
st->codec.palctrl = NULL; st->codec->palctrl = NULL;
a.size = size; a.size = size;
mov_read_default(c, pb, a); mov_read_default(c, pb, a);
#endif #endif
} else { } else {
st->codec.codec_id = codec_get_id(mov_audio_tags, format); st->codec->codec_id = codec_get_id(mov_audio_tags, format);
if(st->codec.codec_id==CODEC_ID_AMR_NB || st->codec.codec_id==CODEC_ID_AMR_WB) //from TS26.244 if(st->codec->codec_id==CODEC_ID_AMR_NB || st->codec->codec_id==CODEC_ID_AMR_WB) //from TS26.244
{ {
#ifdef DEBUG #ifdef DEBUG
av_log(NULL, AV_LOG_DEBUG, "AMR-NB or AMR-WB audio identified!!\n"); av_log(NULL, AV_LOG_DEBUG, "AMR-NB or AMR-WB audio identified!!\n");
@ -1045,21 +1045,21 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
get_byte(pb); //frames_per_sample get_byte(pb); //frames_per_sample
st->duration = AV_NOPTS_VALUE;//Not possible to get from this info, must count number of AMR frames st->duration = AV_NOPTS_VALUE;//Not possible to get from this info, must count number of AMR frames
if(st->codec.codec_id==CODEC_ID_AMR_NB) if(st->codec->codec_id==CODEC_ID_AMR_NB)
{ {
st->codec.sample_rate=8000; st->codec->sample_rate=8000;
st->codec.channels=1; st->codec->channels=1;
} }
else //AMR-WB else //AMR-WB
{ {
st->codec.sample_rate=16000; st->codec->sample_rate=16000;
st->codec.channels=1; st->codec->channels=1;
} }
st->codec.bits_per_sample=16; st->codec->bits_per_sample=16;
st->codec.bit_rate=0; /*It is not possible to tell this before we have st->codec->bit_rate=0; /*It is not possible to tell this before we have
an audio frame and even then every frame can be different*/ an audio frame and even then every frame can be different*/
} }
else if( st->codec.codec_tag == MKTAG( 'm', 'p', '4', 's' )) else if( st->codec->codec_tag == MKTAG( 'm', 'p', '4', 's' ))
{ {
//This is some stuff for the hint track, lets ignore it! //This is some stuff for the hint track, lets ignore it!
//Do some mp4 auto detect. //Do some mp4 auto detect.
@ -1067,7 +1067,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
size-=(16); size-=(16);
url_fskip(pb, size); /* The mp4s atom also contians a esds atom that we can skip*/ url_fskip(pb, size); /* The mp4s atom also contians a esds atom that we can skip*/
} }
else if( st->codec.codec_tag == MKTAG( 'm', 'p', '4', 'a' )) else if( st->codec->codec_tag == MKTAG( 'm', 'p', '4', 'a' ))
{ {
MOV_atom_t a; MOV_atom_t a;
int mp4_version; int mp4_version;
@ -1076,10 +1076,10 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
mp4_version=get_be16(pb);/*version*/ mp4_version=get_be16(pb);/*version*/
get_be16(pb); /*revesion*/ get_be16(pb); /*revesion*/
get_be32(pb); get_be32(pb);
st->codec.channels = get_be16(pb); /* channels */ st->codec->channels = get_be16(pb); /* channels */
st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ st->codec->bits_per_sample = get_be16(pb); /* bits per sample */
get_be32(pb); get_be32(pb);
st->codec.sample_rate = get_be16(pb); /* sample rate, not always correct */ st->codec->sample_rate = get_be16(pb); /* sample rate, not always correct */
get_be16(pb); get_be16(pb);
c->mp4=1; c->mp4=1;
@ -1096,35 +1096,35 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
mov_read_default(c, pb, a); mov_read_default(c, pb, a);
/* Get correct sample rate from extradata */ /* Get correct sample rate from extradata */
if(st->codec.extradata_size) { if(st->codec->extradata_size) {
const int samplerate_table[] = { const int samplerate_table[] = {
96000, 88200, 64000, 48000, 44100, 32000, 96000, 88200, 64000, 48000, 44100, 32000,
24000, 22050, 16000, 12000, 11025, 8000, 24000, 22050, 16000, 12000, 11025, 8000,
7350, 0, 0, 0 7350, 0, 0, 0
}; };
unsigned char *px = st->codec.extradata; unsigned char *px = st->codec->extradata;
// 5 bits objectTypeIndex, 4 bits sampleRateIndex, 4 bits channels // 5 bits objectTypeIndex, 4 bits sampleRateIndex, 4 bits channels
int samplerate_index = ((px[0] & 7) << 1) + ((px[1] >> 7) & 1); int samplerate_index = ((px[0] & 7) << 1) + ((px[1] >> 7) & 1);
st->codec.sample_rate = samplerate_table[samplerate_index]; st->codec->sample_rate = samplerate_table[samplerate_index];
st->codec.channels = (px[1] >> 3) & 15; st->codec->channels = (px[1] >> 3) & 15;
} }
} }
else if( st->codec.codec_tag == MKTAG( 'a', 'l', 'a', 'c' )) else if( st->codec->codec_tag == MKTAG( 'a', 'l', 'a', 'c' ))
{ {
/* Handle alac audio tag + special extradata */ /* Handle alac audio tag + special extradata */
get_be32(pb); /* version */ get_be32(pb); /* version */
get_be32(pb); get_be32(pb);
st->codec.channels = get_be16(pb); /* channels */ st->codec->channels = get_be16(pb); /* channels */
st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ st->codec->bits_per_sample = get_be16(pb); /* bits per sample */
get_be32(pb); get_be32(pb);
st->codec.sample_rate = get_be16(pb); st->codec->sample_rate = get_be16(pb);
get_be16(pb); get_be16(pb);
/* fetch the 36-byte extradata needed for alac decoding */ /* fetch the 36-byte extradata needed for alac decoding */
st->codec.extradata_size = 36; st->codec->extradata_size = 36;
st->codec.extradata = (uint8_t*) st->codec->extradata = (uint8_t*)
av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size); get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
} }
else if(size>=(16+20)) else if(size>=(16+20))
{//16 bytes read, reading atleast 20 more {//16 bytes read, reading atleast 20 more
@ -1136,23 +1136,23 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
get_be16(pb); /* revision level */ get_be16(pb); /* revision level */
get_be32(pb); /* vendor */ get_be32(pb); /* vendor */
st->codec.channels = get_be16(pb); /* channel count */ st->codec->channels = get_be16(pb); /* channel count */
st->codec.bits_per_sample = get_be16(pb); /* sample size */ st->codec->bits_per_sample = get_be16(pb); /* sample size */
/* handle specific s8 codec */ /* handle specific s8 codec */
get_be16(pb); /* compression id = 0*/ get_be16(pb); /* compression id = 0*/
get_be16(pb); /* packet size = 0 */ get_be16(pb); /* packet size = 0 */
st->codec.sample_rate = ((get_be32(pb) >> 16)); st->codec->sample_rate = ((get_be32(pb) >> 16));
//av_log(NULL, AV_LOG_DEBUG, "CODECID %d %d %.4s\n", st->codec.codec_id, CODEC_ID_PCM_S16BE, (char*)&format); //av_log(NULL, AV_LOG_DEBUG, "CODECID %d %d %.4s\n", st->codec->codec_id, CODEC_ID_PCM_S16BE, (char*)&format);
switch (st->codec.codec_id) { switch (st->codec->codec_id) {
case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16BE:
if (st->codec.bits_per_sample == 8) if (st->codec->bits_per_sample == 8)
st->codec.codec_id = CODEC_ID_PCM_S8; st->codec->codec_id = CODEC_ID_PCM_S8;
/* fall */ /* fall */
case CODEC_ID_PCM_U8: case CODEC_ID_PCM_U8:
st->codec.bit_rate = st->codec.sample_rate * 8; st->codec->bit_rate = st->codec->sample_rate * 8;
break; break;
default: default:
; ;
@ -1348,8 +1348,8 @@ av_log(NULL, AV_LOG_DEBUG, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1,
} }
av_set_pts_info(st, 64, 1, c->streams[c->fc->nb_streams-1]->time_scale); av_set_pts_info(st, 64, 1, c->streams[c->fc->nb_streams-1]->time_scale);
// st->codec.time_base.num = 1; // st->codec->time_base.num = 1;
// st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale; // st->codec->time_base.den = c->streams[c->fc->nb_streams-1]->time_scale;
st->nb_frames= total_sample_count; st->nb_frames= total_sample_count;
if(duration) if(duration)
st->duration= duration; st->duration= duration;
@ -1400,7 +1400,7 @@ static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
sc->sample_to_chunk_index = -1; sc->sample_to_chunk_index = -1;
st->priv_data = sc; st->priv_data = sc;
st->codec.codec_type = CODEC_TYPE_MOV_OTHER; st->codec->codec_type = CODEC_TYPE_MOV_OTHER;
st->start_time = 0; /* XXX: check */ st->start_time = 0; /* XXX: check */
c->streams[c->fc->nb_streams-1] = sc; c->streams[c->fc->nb_streams-1] = sc;
@ -1443,8 +1443,8 @@ static int mov_read_tkhd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)
url_fskip(pb, 36); /* display matrix */ url_fskip(pb, 36); /* display matrix */
/* those are fixed-point */ /* those are fixed-point */
/*st->codec.width =*/ get_be32(pb) >> 16; /* track width */ /*st->codec->width =*/ get_be32(pb) >> 16; /* track width */
/*st->codec.height =*/ get_be32(pb) >> 16; /* track height */ /*st->codec->height =*/ get_be32(pb) >> 16; /* track height */
return 0; return 0;
} }
@ -1755,7 +1755,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
#if 1 #if 1
for(i=0; i<s->nb_streams;) { for(i=0; i<s->nb_streams;) {
if(s->streams[i]->codec.codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */ if(s->streams[i]->codec->codec_type == CODEC_TYPE_MOV_OTHER) {/* not audio, not video, delete */
av_free(s->streams[i]); av_free(s->streams[i]);
for(j=i+1; j<s->nb_streams; j++) for(j=i+1; j<s->nb_streams; j++)
s->streams[j-1] = s->streams[j]; s->streams[j-1] = s->streams[j];
@ -1894,7 +1894,7 @@ again:
{ {
// I can't figure out why for PCM audio sample_size is always 1 // I can't figure out why for PCM audio sample_size is always 1
// (it should actually be channels*bits_per_second/8) but it is. // (it should actually be channels*bits_per_second/8) but it is.
AVCodecContext* cod = &s->streams[sc->ffindex]->codec; AVCodecContext* cod = s->streams[sc->ffindex]->codec;
if (sc->sample_size == 1 && (cod->codec_id == CODEC_ID_PCM_S16BE || cod->codec_id == CODEC_ID_PCM_S16LE)) if (sc->sample_size == 1 && (cod->codec_id == CODEC_ID_PCM_S16BE || cod->codec_id == CODEC_ID_PCM_S16LE))
foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8; foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8;
else else

View File

@ -1256,11 +1256,11 @@ int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s)
static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s)
{ {
int AudioRate = s->streams[1]->codec.sample_rate; int AudioRate = s->streams[1]->codec->sample_rate;
int FrameRate = ((s->streams[0]->codec.time_base.den) * (0x10000))/ (s->streams[0]->codec.time_base.num); int FrameRate = ((s->streams[0]->codec->time_base.den) * (0x10000))/ (s->streams[0]->codec->time_base.num);
//printf("audiorate = %d\n",AudioRate); //printf("audiorate = %d\n",AudioRate);
//printf("framerate = %d / %d = 0x%x\n",s->streams[0]->codec.time_base.den,s->streams[0]->codec.time_base.num,FrameRate); //printf("framerate = %d / %d = 0x%x\n",s->streams[0]->codec->time_base.den,s->streams[0]->codec->time_base.num,FrameRate);
put_be32(pb, 0x94 ); /* size */ put_be32(pb, 0x94 ); /* size */
put_tag(pb, "uuid"); put_tag(pb, "uuid");
@ -1302,8 +1302,8 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s)
put_be32(pb, 0xc0 ); put_be32(pb, 0xc0 );
put_be32(pb, FrameRate); // was 0xefc29 put_be32(pb, FrameRate); // was 0xefc29
put_be32(pb, FrameRate ); // was 0xefc29 put_be32(pb, FrameRate ); // was 0xefc29
put_be16(pb, s->streams[0]->codec.width); put_be16(pb, s->streams[0]->codec->width);
put_be16(pb, s->streams[0]->codec.height); put_be16(pb, s->streams[0]->codec->height);
put_be32(pb, 0x010001 ); put_be32(pb, 0x010001 );
} }
@ -1314,7 +1314,7 @@ static int mov_write_header(AVFormatContext *s)
int i; int i;
for(i=0; i<s->nb_streams; i++){ for(i=0; i<s->nb_streams; i++){
AVCodecContext *c= &s->streams[i]->codec; AVCodecContext *c= s->streams[i]->codec;
if (c->codec_type == CODEC_TYPE_VIDEO){ if (c->codec_type == CODEC_TYPE_VIDEO){
if (!codec_get_tag(codec_movvideo_tags, c->codec_id)){ if (!codec_get_tag(codec_movvideo_tags, c->codec_id)){
@ -1367,7 +1367,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
MOVContext *mov = s->priv_data; MOVContext *mov = s->priv_data;
ByteIOContext *pb = &s->pb; ByteIOContext *pb = &s->pb;
AVCodecContext *enc = &s->streams[pkt->stream_index]->codec; AVCodecContext *enc = s->streams[pkt->stream_index]->codec;
MOVTrack* trk = &mov->tracks[pkt->stream_index]; MOVTrack* trk = &mov->tracks[pkt->stream_index];
int cl, id; int cl, id;
unsigned int samplesInChunk = 0; unsigned int samplesInChunk = 0;

View File

@ -251,8 +251,8 @@ static int mp3_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_MP3; st->codec->codec_id = CODEC_ID_MP3;
st->need_parsing = 1; st->need_parsing = 1;
/* try to get the TAG */ /* try to get the TAG */

View File

@ -360,26 +360,26 @@ static int mpeg_mux_init(AVFormatContext *ctx)
av_set_pts_info(st, 64, 1, 90000); av_set_pts_info(st, 64, 1, 90000);
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
if (st->codec.codec_id == CODEC_ID_AC3) { if (st->codec->codec_id == CODEC_ID_AC3) {
stream->id = ac3_id++; stream->id = ac3_id++;
} else if (st->codec.codec_id == CODEC_ID_DTS) { } else if (st->codec->codec_id == CODEC_ID_DTS) {
stream->id = dts_id++; stream->id = dts_id++;
} else if (st->codec.codec_id == CODEC_ID_PCM_S16BE) { } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) {
stream->id = lpcm_id++; stream->id = lpcm_id++;
for(j = 0; j < 4; j++) { for(j = 0; j < 4; j++) {
if (lpcm_freq_tab[j] == st->codec.sample_rate) if (lpcm_freq_tab[j] == st->codec->sample_rate)
break; break;
} }
if (j == 4) if (j == 4)
goto fail; goto fail;
if (st->codec.channels > 8) if (st->codec->channels > 8)
return -1; return -1;
stream->lpcm_header[0] = 0x0c; stream->lpcm_header[0] = 0x0c;
stream->lpcm_header[1] = (st->codec.channels - 1) | (j << 4); stream->lpcm_header[1] = (st->codec->channels - 1) | (j << 4);
stream->lpcm_header[2] = 0x80; stream->lpcm_header[2] = 0x80;
stream->lpcm_align = st->codec.channels * 2; stream->lpcm_align = st->codec->channels * 2;
} else { } else {
stream->id = mpa_id++; stream->id = mpa_id++;
} }
@ -391,8 +391,8 @@ static int mpeg_mux_init(AVFormatContext *ctx)
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
stream->id = mpv_id++; stream->id = mpv_id++;
if (st->codec.rc_buffer_size) if (st->codec->rc_buffer_size)
stream->max_buffer_size = 6*1024 + st->codec.rc_buffer_size/8; stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8;
else else
stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default
#if 0 #if 0
@ -422,10 +422,10 @@ static int mpeg_mux_init(AVFormatContext *ctx)
st = ctx->streams[i]; st = ctx->streams[i];
stream = (StreamInfo*) st->priv_data; stream = (StreamInfo*) st->priv_data;
if(st->codec.rc_max_rate || stream->id==VIDEO_ID) if(st->codec->rc_max_rate || stream->id==VIDEO_ID)
codec_rate= st->codec.rc_max_rate; codec_rate= st->codec->rc_max_rate;
else else
codec_rate= st->codec.bit_rate; codec_rate= st->codec->bit_rate;
if(!codec_rate) if(!codec_rate)
codec_rate= (1<<21)*8*50/ctx->nb_streams; codec_rate= (1<<21)*8*50/ctx->nb_streams;
@ -1073,7 +1073,7 @@ retry:
/* for subtitle, a single PES packet must be generated, /* for subtitle, a single PES packet must be generated,
so we flush after every single subtitle packet */ so we flush after every single subtitle packet */
if(s->packet_size > avail_data && !flush if(s->packet_size > avail_data && !flush
&& st->codec.codec_type != CODEC_TYPE_SUBTITLE) && st->codec->codec_type != CODEC_TYPE_SUBTITLE)
return 0; return 0;
if(avail_data==0) if(avail_data==0)
continue; continue;
@ -1183,7 +1183,7 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt)
int64_t pts, dts; int64_t pts, dts;
PacketDesc *pkt_desc; PacketDesc *pkt_desc;
const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE); const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE);
const int is_iframe = st->codec.codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY); const int is_iframe = st->codec->codec_type == CODEC_TYPE_VIDEO && (pkt->flags & PKT_FLAG_KEY);
pts= pkt->pts; pts= pkt->pts;
dts= pkt->dts; dts= pkt->dts;
@ -1634,8 +1634,8 @@ static int mpegps_read_packet(AVFormatContext *s,
st = av_new_stream(s, startcode); st = av_new_stream(s, startcode);
if (!st) if (!st)
goto skip; goto skip;
st->codec.codec_type = type; st->codec->codec_type = type;
st->codec.codec_id = codec_id; st->codec->codec_id = codec_id;
if (codec_id != CODEC_ID_PCM_S16BE) if (codec_id != CODEC_ID_PCM_S16BE)
st->need_parsing = 1; st->need_parsing = 1;
found: found:
@ -1653,9 +1653,9 @@ static int mpegps_read_packet(AVFormatContext *s,
get_byte(&s->pb); /* dynamic range control (0x80 = off) */ get_byte(&s->pb); /* dynamic range control (0x80 = off) */
len -= 3; len -= 3;
freq = (b1 >> 4) & 3; freq = (b1 >> 4) & 3;
st->codec.sample_rate = lpcm_freq_tab[freq]; st->codec->sample_rate = lpcm_freq_tab[freq];
st->codec.channels = 1 + (b1 & 7); st->codec->channels = 1 + (b1 & 7);
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * 2; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * 2;
} }
av_new_packet(pkt, len); av_new_packet(pkt, len);
get_buffer(&s->pb, pkt->data, pkt->size); get_buffer(&s->pb, pkt->data, pkt->size);

View File

@ -493,7 +493,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len)
} }
if (stream_type == STREAM_TYPE_SUBTITLE_DVB) { if (stream_type == STREAM_TYPE_SUBTITLE_DVB) {
st->codec.sub_id = (anc_page << 16) | comp_page; st->codec->sub_id = (anc_page << 16) | comp_page;
} }
} }
} }
@ -921,8 +921,8 @@ static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code)
if (st) { if (st) {
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
st->priv_data = pes; st->priv_data = pes;
st->codec.codec_type = codec_type; st->codec->codec_type = codec_type;
st->codec.codec_id = codec_id; st->codec->codec_id = codec_id;
st->need_parsing = 1; st->need_parsing = 1;
pes->st = st; pes->st = st;
} }
@ -1253,8 +1253,8 @@ static int mpegts_read_header(AVFormatContext *s,
if (!st) if (!st)
goto fail; goto fail;
av_set_pts_info(st, 60, 1, 27000000); av_set_pts_info(st, 60, 1, 27000000);
st->codec.codec_type = CODEC_TYPE_DATA; st->codec->codec_type = CODEC_TYPE_DATA;
st->codec.codec_id = CODEC_ID_MPEG2TS; st->codec->codec_id = CODEC_ID_MPEG2TS;
/* we iterate until we find two PCRs to estimate the bitrate */ /* we iterate until we find two PCRs to estimate the bitrate */
pcr_pid = -1; pcr_pid = -1;
@ -1283,7 +1283,7 @@ static int mpegts_read_header(AVFormatContext *s,
ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]); ts->pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]);
ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; ts->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0];
s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr; s->bit_rate = (TS_PACKET_SIZE * 8) * 27e6 / ts->pcr_incr;
st->codec.bit_rate = s->bit_rate; st->codec->bit_rate = s->bit_rate;
st->start_time = ts->cur_pcr; st->start_time = ts->cur_pcr;
#if 0 #if 0
printf("start=%0.3f pcr=%0.3f incr=%d\n", printf("start=%0.3f pcr=%0.3f incr=%d\n",

View File

@ -262,7 +262,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
for(i = 0; i < s->nb_streams; i++) { for(i = 0; i < s->nb_streams; i++) {
AVStream *st = s->streams[i]; AVStream *st = s->streams[i];
MpegTSWriteStream *ts_st = st->priv_data; MpegTSWriteStream *ts_st = st->priv_data;
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO: case CODEC_ID_MPEG2VIDEO:
stream_type = STREAM_TYPE_VIDEO_MPEG2; stream_type = STREAM_TYPE_VIDEO_MPEG2;
@ -293,7 +293,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service)
q += 2; /* patched after */ q += 2; /* patched after */
/* write optional descriptors here */ /* write optional descriptors here */
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
if (strlen(st->language) == 3) { if (strlen(st->language) == 3) {
*q++ = 0x0a; /* ISO 639 language descriptor */ *q++ = 0x0a; /* ISO 639 language descriptor */
@ -452,10 +452,10 @@ static int mpegts_write_header(AVFormatContext *s)
ts_st->pid = DEFAULT_START_PID + i; ts_st->pid = DEFAULT_START_PID + i;
ts_st->payload_pts = AV_NOPTS_VALUE; ts_st->payload_pts = AV_NOPTS_VALUE;
/* update PCR pid by using the first video stream */ /* update PCR pid by using the first video stream */
if (st->codec.codec_type == CODEC_TYPE_VIDEO && if (st->codec->codec_type == CODEC_TYPE_VIDEO &&
service->pcr_pid == 0x1fff) service->pcr_pid == 0x1fff)
service->pcr_pid = ts_st->pid; service->pcr_pid = ts_st->pid;
total_bit_rate += st->codec.bit_rate; total_bit_rate += st->codec->bit_rate;
} }
/* if no video stream, use the first stream as PCR */ /* if no video stream, use the first stream as PCR */
@ -570,15 +570,15 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
*q++ = 0x00; *q++ = 0x00;
*q++ = 0x01; *q++ = 0x01;
private_code = 0; private_code = 0;
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
*q++ = 0xe0; *q++ = 0xe0;
} else if (st->codec.codec_type == CODEC_TYPE_AUDIO && } else if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
(st->codec.codec_id == CODEC_ID_MP2 || (st->codec->codec_id == CODEC_ID_MP2 ||
st->codec.codec_id == CODEC_ID_MP3)) { st->codec->codec_id == CODEC_ID_MP3)) {
*q++ = 0xc0; *q++ = 0xc0;
} else { } else {
*q++ = 0xbd; *q++ = 0xbd;
if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) { if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
private_code = 0x20; private_code = 0x20;
} }
} }
@ -593,7 +593,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
*q++ = len; *q++ = len;
val = 0x80; val = 0x80;
/* data alignment indicator is required for subtitle data */ /* data alignment indicator is required for subtitle data */
if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) if (st->codec->codec_type == CODEC_TYPE_SUBTITLE)
val |= 0x04; val |= 0x04;
*q++ = val; *q++ = val;
if (pts != AV_NOPTS_VALUE) { if (pts != AV_NOPTS_VALUE) {
@ -660,7 +660,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt)
MpegTSWriteStream *ts_st = st->priv_data; MpegTSWriteStream *ts_st = st->priv_data;
int len, max_payload_size; int len, max_payload_size;
if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) { if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) {
/* for subtitle, a single PES packet must be generated */ /* for subtitle, a single PES packet must be generated */
mpegts_write_pes(s, st, buf, size, pkt->pts); mpegts_write_pes(s, st, buf, size, pkt->pts);
return 0; return 0;

View File

@ -439,12 +439,12 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
if (!nst) if (!nst)
goto fail; goto fail;
st->priv_data = nst; st->priv_data = nst;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_tag = vtag; st->codec->codec_tag = vtag;
st->codec.codec_id = codec_get_id(nsv_codec_video_tags, vtag); st->codec->codec_id = codec_get_id(nsv_codec_video_tags, vtag);
st->codec.width = vwidth; st->codec->width = vwidth;
st->codec.height = vheight; st->codec->height = vheight;
st->codec.bits_per_sample = 24; /* depth XXX */ st->codec->bits_per_sample = 24; /* depth XXX */
av_set_pts_info(st, 64, framerate.den, framerate.num); av_set_pts_info(st, 64, framerate.den, framerate.num);
st->start_time = 0; st->start_time = 0;
@ -460,17 +460,17 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap)
if (!nst) if (!nst)
goto fail; goto fail;
st->priv_data = nst; st->priv_data = nst;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = atag; st->codec->codec_tag = atag;
st->codec.codec_id = codec_get_id(nsv_codec_audio_tags, atag); st->codec->codec_id = codec_get_id(nsv_codec_audio_tags, atag);
st->start_time = 0; st->start_time = 0;
// st->duration = nsv->duration; //FIXME // st->duration = nsv->duration; //FIXME
st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */ st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */
/* XXX:FIXME */ /* XXX:FIXME */
//st->codec.channels = 2; //XXX:channels; //st->codec->channels = 2; //XXX:channels;
//st->codec.sample_rate = 1000; //st->codec->sample_rate = 1000;
//av_set_pts_info(st, 64, 1, st->codec.sample_rate); //av_set_pts_info(st, 64, 1, st->codec->sample_rate);
#endif #endif
} }
@ -606,7 +606,7 @@ null_chunk_retry:
pkt = &nsv->ahead[NSV_ST_AUDIO]; pkt = &nsv->ahead[NSV_ST_AUDIO];
/* read raw audio specific header on the first audio chunk... */ /* read raw audio specific header on the first audio chunk... */
/* on ALL audio chunks ?? seems so! */ /* on ALL audio chunks ?? seems so! */
if (asize && st[NSV_ST_AUDIO]->codec.codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) { if (asize && st[NSV_ST_AUDIO]->codec->codec_tag == MKTAG('P', 'C', 'M', ' ')/* && fill_header*/) {
uint8_t bps; uint8_t bps;
uint8_t channels; uint8_t channels;
uint16_t samplerate; uint16_t samplerate;
@ -622,13 +622,13 @@ null_chunk_retry:
} }
bps /= channels; // ??? bps /= channels; // ???
if (bps == 8) if (bps == 8)
st[NSV_ST_AUDIO]->codec.codec_id = CODEC_ID_PCM_U8; st[NSV_ST_AUDIO]->codec->codec_id = CODEC_ID_PCM_U8;
samplerate /= 4;/* UGH ??? XXX */ samplerate /= 4;/* UGH ??? XXX */
channels = 1; channels = 1;
st[NSV_ST_AUDIO]->codec.channels = channels; st[NSV_ST_AUDIO]->codec->channels = channels;
st[NSV_ST_AUDIO]->codec.sample_rate = samplerate; st[NSV_ST_AUDIO]->codec->sample_rate = samplerate;
av_set_pts_info(st[NSV_ST_AUDIO], 64, 1, av_set_pts_info(st[NSV_ST_AUDIO], 64, 1,
st[NSV_ST_AUDIO]->codec.sample_rate); st[NSV_ST_AUDIO]->codec->sample_rate);
PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %ld\n", bps, channels, samplerate)); PRINT(("NSV RAWAUDIO: bps %d, nchan %d, srate %ld\n", bps, channels, samplerate));
} }
} }
@ -704,8 +704,8 @@ static int nsv_read_close(AVFormatContext *s)
av_free(ast->index_entries); av_free(ast->index_entries);
av_free(ast); av_free(ast);
} }
av_free(st->codec.extradata); av_free(st->codec->extradata);
av_free(st->codec.palctrl); av_free(st->codec->palctrl);
} }
#endif #endif

View File

@ -155,7 +155,7 @@ static void build_frame_code(AVFormatContext *s){
for(stream_id= 0; stream_id<s->nb_streams; stream_id++){ for(stream_id= 0; stream_id<s->nb_streams; stream_id++){
int start2= start + (end-start)*stream_id / s->nb_streams; int start2= start + (end-start)*stream_id / s->nb_streams;
int end2 = start + (end-start)*(stream_id+1) / s->nb_streams; int end2 = start + (end-start)*(stream_id+1) / s->nb_streams;
AVCodecContext *codec = &s->streams[stream_id]->codec; AVCodecContext *codec = s->streams[stream_id]->codec;
int is_audio= codec->codec_type == CODEC_TYPE_AUDIO; int is_audio= codec->codec_type == CODEC_TYPE_AUDIO;
int intra_only= /*codec->intra_only || */is_audio; int intra_only= /*codec->intra_only || */is_audio;
int pred_count; int pred_count;
@ -579,7 +579,7 @@ static int nut_write_header(AVFormatContext *s)
{ {
int nom, denom, ssize; int nom, denom, ssize;
codec = &s->streams[i]->codec; codec = s->streams[i]->codec;
put_be64(bc, STREAM_STARTCODE); put_be64(bc, STREAM_STARTCODE);
put_packetheader(nut, bc, 120 + codec->extradata_size, 1); put_packetheader(nut, bc, 120 + codec->extradata_size, 1);
@ -674,7 +674,7 @@ static int nut_write_header(AVFormatContext *s)
put_str(bc, s->copyright); put_str(bc, s->copyright);
} }
/* encoder */ /* encoder */
if(!(s->streams[0]->codec.flags & CODEC_FLAG_BITEXACT)){ if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)){
put_v(bc, 13); /* type */ put_v(bc, 13); /* type */
put_str(bc, LIBAVFORMAT_IDENT); put_str(bc, LIBAVFORMAT_IDENT);
} }
@ -707,7 +707,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt)
int size= pkt->size; int size= pkt->size;
int stream_index= pkt->stream_index; int stream_index= pkt->stream_index;
enc = &s->streams[stream_index]->codec; enc = s->streams[stream_index]->codec;
key_frame = !!(pkt->flags & PKT_FLAG_KEY); key_frame = !!(pkt->flags & PKT_FLAG_KEY);
frame_type=0; frame_type=0;
@ -949,27 +949,27 @@ static int decode_stream_header(NUTContext *nut){
class = get_v(bc); class = get_v(bc);
tmp = get_vb(bc); tmp = get_vb(bc);
st->codec.codec_tag= tmp; st->codec->codec_tag= tmp;
switch(class) switch(class)
{ {
case 0: case 0:
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = codec_get_bmp_id(tmp); st->codec->codec_id = codec_get_bmp_id(tmp);
if (st->codec.codec_id == CODEC_ID_NONE) if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
break; break;
case 1: case 1:
case 32: //compatibility case 32: //compatibility
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = codec_get_wav_id(tmp); st->codec->codec_id = codec_get_wav_id(tmp);
if (st->codec.codec_id == CODEC_ID_NONE) if (st->codec->codec_id == CODEC_ID_NONE)
av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
break; break;
case 2: case 2:
// st->codec.codec_type = CODEC_TYPE_TEXT; // st->codec->codec_type = CODEC_TYPE_TEXT;
// break; // break;
case 3: case 3:
st->codec.codec_type = CODEC_TYPE_DATA; st->codec->codec_type = CODEC_TYPE_DATA;
break; break;
default: default:
av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class); av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class);
@ -980,33 +980,33 @@ static int decode_stream_header(NUTContext *nut){
nom = get_v(bc); nom = get_v(bc);
denom = get_v(bc); denom = get_v(bc);
nut->stream[stream_id].msb_timestamp_shift = get_v(bc); nut->stream[stream_id].msb_timestamp_shift = get_v(bc);
st->codec.has_b_frames= st->codec->has_b_frames=
nut->stream[stream_id].decode_delay= get_v(bc); nut->stream[stream_id].decode_delay= get_v(bc);
get_byte(bc); /* flags */ get_byte(bc); /* flags */
/* codec specific data headers */ /* codec specific data headers */
while(get_v(bc) != 0){ while(get_v(bc) != 0){
st->codec.extradata_size= get_v(bc); st->codec->extradata_size= get_v(bc);
if((unsigned)st->codec.extradata_size > (1<<30)) if((unsigned)st->codec->extradata_size > (1<<30))
return -1; return -1;
st->codec.extradata= av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
get_buffer(bc, st->codec.extradata, st->codec.extradata_size); get_buffer(bc, st->codec->extradata, st->codec->extradata_size);
// url_fskip(bc, get_v(bc)); // url_fskip(bc, get_v(bc));
} }
if (st->codec.codec_type == CODEC_TYPE_VIDEO) /* VIDEO */ if (st->codec->codec_type == CODEC_TYPE_VIDEO) /* VIDEO */
{ {
st->codec.width = get_v(bc); st->codec->width = get_v(bc);
st->codec.height = get_v(bc); st->codec->height = get_v(bc);
st->codec.sample_aspect_ratio.num= get_v(bc); st->codec->sample_aspect_ratio.num= get_v(bc);
st->codec.sample_aspect_ratio.den= get_v(bc); st->codec->sample_aspect_ratio.den= get_v(bc);
get_v(bc); /* csp type */ get_v(bc); /* csp type */
} }
if (st->codec.codec_type == CODEC_TYPE_AUDIO) /* AUDIO */ if (st->codec->codec_type == CODEC_TYPE_AUDIO) /* AUDIO */
{ {
st->codec.sample_rate = get_v(bc); st->codec->sample_rate = get_v(bc);
get_v(bc); // samplerate_den get_v(bc); // samplerate_den
st->codec.channels = get_v(bc); st->codec->channels = get_v(bc);
} }
if(check_checksum(bc)){ if(check_checksum(bc)){
av_log(s, AV_LOG_ERROR, "Stream header %d checksum mismatch\n", stream_id); av_log(s, AV_LOG_ERROR, "Stream header %d checksum mismatch\n", stream_id);
@ -1407,7 +1407,7 @@ static int nut_read_close(AVFormatContext *s)
int i; int i;
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
av_freep(&s->streams[i]->codec.extradata); av_freep(&s->streams[i]->codec->extradata);
} }
av_freep(&nut->stream); av_freep(&nut->stream);

View File

@ -39,7 +39,7 @@ static int ogg_write_header(AVFormatContext *avfcontext)
ogg_stream_init(&context->os, 31415); ogg_stream_init(&context->os, 31415);
for(n = 0 ; n < avfcontext->nb_streams ; n++) { for(n = 0 ; n < avfcontext->nb_streams ; n++) {
AVCodecContext *codec = &avfcontext->streams[n]->codec; AVCodecContext *codec = avfcontext->streams[n]->codec;
uint8_t *p= codec->extradata; uint8_t *p= codec->extradata;
av_set_pts_info(avfcontext->streams[n], 60, 1, AV_TIME_BASE); av_set_pts_info(avfcontext->streams[n], 60, 1, AV_TIME_BASE);
@ -65,7 +65,7 @@ static int ogg_write_header(AVFormatContext *avfcontext)
static int ogg_write_packet(AVFormatContext *avfcontext, AVPacket *pkt) static int ogg_write_packet(AVFormatContext *avfcontext, AVPacket *pkt)
{ {
OggContext *context = avfcontext->priv_data ; OggContext *context = avfcontext->priv_data ;
AVCodecContext *avctx= &avfcontext->streams[pkt->stream_index]->codec; AVCodecContext *avctx= avfcontext->streams[pkt->stream_index]->codec;
ogg_packet *op= &context->op; ogg_packet *op= &context->op;
ogg_page og ; ogg_page og ;
int64_t pts; int64_t pts;

View File

@ -430,7 +430,7 @@ ogg_gptopts (AVFormatContext * s, int i, uint64_t gp)
ogg_t *ogg = s->priv_data; ogg_t *ogg = s->priv_data;
ogg_stream_t *os = ogg->streams + i; ogg_stream_t *os = ogg->streams + i;
AVStream *st = s->streams[i]; AVStream *st = s->streams[i];
AVCodecContext *codec = &st->codec; AVCodecContext *codec = st->codec;
uint64_t pts = AV_NOPTS_VALUE; uint64_t pts = AV_NOPTS_VALUE;
if(os->codec->gptopts){ if(os->codec->gptopts){
@ -537,7 +537,7 @@ ogg_read_close (AVFormatContext * s)
for (i = 0; i < ogg->nstreams; i++){ for (i = 0; i < ogg->nstreams; i++){
av_free (ogg->streams[i].buf); av_free (ogg->streams[i].buf);
av_free (ogg->streams[i].private); av_free (ogg->streams[i].private);
av_freep (&s->streams[i]->codec.extradata); av_freep (&s->streams[i]->codec->extradata);
} }
av_free (ogg->streams); av_free (ogg->streams);
return 0; return 0;

View File

@ -52,17 +52,17 @@ flac_header (AVFormatContext * s, int idx)
skip_bits(&gb, 16*2+24*2); skip_bits(&gb, 16*2+24*2);
st->codec.sample_rate = get_bits_long(&gb, 20); st->codec->sample_rate = get_bits_long(&gb, 20);
st->codec.channels = get_bits(&gb, 3) + 1; st->codec->channels = get_bits(&gb, 3) + 1;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_FLAC; st->codec->codec_id = CODEC_ID_FLAC;
st->codec.extradata = st->codec->extradata =
av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
memcpy (st->codec.extradata, os->buf + os->pstart + 5 + 4 + 4 + 4, memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,
FLAC_STREAMINFO_SIZE); FLAC_STREAMINFO_SIZE);
st->codec.extradata_size = FLAC_STREAMINFO_SIZE; st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
} else if (mdt == 4) { } else if (mdt == 4) {
vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4); vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);
} }

View File

@ -40,7 +40,7 @@ theora_header (AVFormatContext * s, int idx)
ogg_stream_t *os = ogg->streams + idx; ogg_stream_t *os = ogg->streams + idx;
AVStream *st = s->streams[idx]; AVStream *st = s->streams[idx];
theora_params_t *thp = os->private; theora_params_t *thp = os->private;
int cds = st->codec.extradata_size + os->psize + 2; int cds = st->codec->extradata_size + os->psize + 2;
uint8_t *cdp; uint8_t *cdp;
if(!(os->buf[os->pstart] & 0x80)) if(!(os->buf[os->pstart] & 0x80))
@ -62,33 +62,33 @@ theora_header (AVFormatContext * s, int idx)
return -1; return -1;
skip_bits(&gb, 8); /* revision */ skip_bits(&gb, 8); /* revision */
st->codec.width = get_bits(&gb, 16) << 4; st->codec->width = get_bits(&gb, 16) << 4;
st->codec.height = get_bits(&gb, 16) << 4; st->codec->height = get_bits(&gb, 16) << 4;
skip_bits(&gb, 64); skip_bits(&gb, 64);
st->codec.time_base.den = get_bits(&gb, 32); st->codec->time_base.den = get_bits(&gb, 32);
st->codec.time_base.num = get_bits(&gb, 32); st->codec->time_base.num = get_bits(&gb, 32);
st->codec.sample_aspect_ratio.num = get_bits(&gb, 24); st->codec->sample_aspect_ratio.num = get_bits(&gb, 24);
st->codec.sample_aspect_ratio.den = get_bits(&gb, 24); st->codec->sample_aspect_ratio.den = get_bits(&gb, 24);
skip_bits(&gb, 38); skip_bits(&gb, 38);
thp->gpshift = get_bits(&gb, 5); thp->gpshift = get_bits(&gb, 5);
thp->gpmask = (1 << thp->gpshift) - 1; thp->gpmask = (1 << thp->gpshift) - 1;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_THEORA; st->codec->codec_id = CODEC_ID_THEORA;
} else if (os->buf[os->pstart] == 0x83) { } else if (os->buf[os->pstart] == 0x83) {
vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);
} }
st->codec.extradata = av_realloc (st->codec.extradata, cds); st->codec->extradata = av_realloc (st->codec->extradata, cds);
cdp = st->codec.extradata + st->codec.extradata_size; cdp = st->codec->extradata + st->codec->extradata_size;
*cdp++ = os->psize >> 8; *cdp++ = os->psize >> 8;
*cdp++ = os->psize & 0xff; *cdp++ = os->psize & 0xff;
memcpy (cdp, os->buf + os->pstart, os->psize); memcpy (cdp, os->buf + os->pstart, os->psize);
st->codec.extradata_size = cds; st->codec->extradata_size = cds;
return 1; return 1;
} }
@ -103,8 +103,8 @@ theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp)
uint64_t iframe = gp >> thp->gpshift; uint64_t iframe = gp >> thp->gpshift;
uint64_t pframe = gp & thp->gpmask; uint64_t pframe = gp & thp->gpmask;
return (iframe + pframe) * AV_TIME_BASE * st->codec.time_base.num / return (iframe + pframe) * AV_TIME_BASE * st->codec->time_base.num /
st->codec.time_base.den; st->codec->time_base.den;
} }
ogg_codec_t theora_codec = { ogg_codec_t theora_codec = {

View File

@ -178,19 +178,19 @@ vorbis_header (AVFormatContext * s, int idx)
memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize); memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize);
if (os->buf[os->pstart] == 1) { if (os->buf[os->pstart] == 1) {
uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels
st->codec.channels = *p++; st->codec->channels = *p++;
st->codec.sample_rate = le2me_32 (unaligned32 (p)); st->codec->sample_rate = le2me_32 (unaligned32 (p));
p += 8; //skip maximum and and nominal bitrate p += 8; //skip maximum and and nominal bitrate
st->codec.bit_rate = le2me_32 (unaligned32 (p)); //Minimum bitrate st->codec->bit_rate = le2me_32 (unaligned32 (p)); //Minimum bitrate
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_VORBIS; st->codec->codec_id = CODEC_ID_VORBIS;
} else if (os->buf[os->pstart] == 3) { } else if (os->buf[os->pstart] == 3) {
vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8);
} else { } else {
st->codec.extradata_size = st->codec->extradata_size =
fixup_vorbis_headers(s, priv, &st->codec.extradata); fixup_vorbis_headers(s, priv, &st->codec->extradata);
} }
return os->seq < 3; return os->seq < 3;

View File

@ -182,11 +182,11 @@ static int str_read_header(AVFormatContext *s,
str->channels[channel].video_stream_index = st->index; str->channels[channel].video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_MDEC; st->codec->codec_id = CODEC_ID_MDEC;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = str->channels[channel].width; st->codec->width = str->channels[channel].width;
st->codec.height = str->channels[channel].height; st->codec->height = str->channels[channel].height;
} }
break; break;
@ -212,13 +212,13 @@ static int str_read_header(AVFormatContext *s,
str->channels[channel].audio_stream_index = st->index; str->channels[channel].audio_stream_index = st->index;
fmt = sector[0x13]; fmt = sector[0x13];
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_ADPCM_XA; st->codec->codec_id = CODEC_ID_ADPCM_XA;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.channels = (fmt&1)?2:1; st->codec->channels = (fmt&1)?2:1;
st->codec.sample_rate = (fmt&4)?18900:37800; st->codec->sample_rate = (fmt&4)?18900:37800;
// st->codec.bit_rate = 0; //FIXME; // st->codec->bit_rate = 0; //FIXME;
st->codec.block_align = 128; st->codec->block_align = 128;
} }
break; break;

View File

@ -50,25 +50,25 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (ap) { if (ap) {
id = s->iformat->value; id = s->iformat->value;
if (id == CODEC_ID_RAWVIDEO) { if (id == CODEC_ID_RAWVIDEO) {
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
} else { } else {
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
} }
st->codec.codec_id = id; st->codec->codec_id = id;
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
st->codec.sample_rate = ap->sample_rate; st->codec->sample_rate = ap->sample_rate;
st->codec.channels = ap->channels; st->codec->channels = ap->channels;
av_set_pts_info(st, 64, 1, st->codec.sample_rate); av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
st->codec.width = ap->width; st->codec->width = ap->width;
st->codec.height = ap->height; st->codec->height = ap->height;
st->codec.pix_fmt = ap->pix_fmt; st->codec->pix_fmt = ap->pix_fmt;
if(st->codec.pix_fmt == PIX_FMT_NONE) if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec.pix_fmt= PIX_FMT_YUV420P; st->codec->pix_fmt= PIX_FMT_YUV420P;
break; break;
default: default:
return -1; return -1;
@ -133,24 +133,24 @@ int pcm_read_seek(AVFormatContext *s,
int64_t pos; int64_t pos;
st = s->streams[0]; st = s->streams[0];
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_U16BE: case CODEC_ID_PCM_U16BE:
block_align = 2 * st->codec.channels; block_align = 2 * st->codec->channels;
byte_rate = block_align * st->codec.sample_rate; byte_rate = block_align * st->codec->sample_rate;
break; break;
case CODEC_ID_PCM_S8: case CODEC_ID_PCM_S8:
case CODEC_ID_PCM_U8: case CODEC_ID_PCM_U8:
case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_MULAW:
case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_ALAW:
block_align = st->codec.channels; block_align = st->codec->channels;
byte_rate = block_align * st->codec.sample_rate; byte_rate = block_align * st->codec->sample_rate;
break; break;
default: default:
block_align = st->codec.block_align; block_align = st->codec->block_align;
byte_rate = st->codec.bit_rate / 8; byte_rate = st->codec->bit_rate / 8;
break; break;
} }
@ -180,8 +180,8 @@ static int ac3_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_AC3; st->codec->codec_id = CODEC_ID_AC3;
st->need_parsing = 1; st->need_parsing = 1;
/* the parameters will be extracted from the compressed bitstream */ /* the parameters will be extracted from the compressed bitstream */
return 0; return 0;
@ -195,8 +195,8 @@ static int shorten_read_header(AVFormatContext *s,
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_SHORTEN; st->codec->codec_id = CODEC_ID_SHORTEN;
st->need_parsing = 1; st->need_parsing = 1;
/* the parameters will be extracted from the compressed bitstream */ /* the parameters will be extracted from the compressed bitstream */
return 0; return 0;
@ -212,8 +212,8 @@ static int dts_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_DTS; st->codec->codec_id = CODEC_ID_DTS;
st->need_parsing = 1; st->need_parsing = 1;
/* the parameters will be extracted from the compressed bitstream */ /* the parameters will be extracted from the compressed bitstream */
return 0; return 0;
@ -229,17 +229,17 @@ static int video_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = s->iformat->value; st->codec->codec_id = s->iformat->value;
st->need_parsing = 1; st->need_parsing = 1;
/* for mjpeg, specify frame rate */ /* for mjpeg, specify frame rate */
/* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/ /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/
if (ap && ap->time_base.num) { if (ap && ap->time_base.num) {
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
} else if ( st->codec.codec_id == CODEC_ID_MJPEG || } else if ( st->codec->codec_id == CODEC_ID_MJPEG ||
st->codec.codec_id == CODEC_ID_MPEG4 || st->codec->codec_id == CODEC_ID_MPEG4 ||
st->codec.codec_id == CODEC_ID_H264) { st->codec->codec_id == CODEC_ID_H264) {
av_set_pts_info(st, 64, 1, 25); av_set_pts_info(st, 64, 1, 25);
} }
@ -609,10 +609,10 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
int packet_size, ret, width, height; int packet_size, ret, width, height;
AVStream *st = s->streams[0]; AVStream *st = s->streams[0];
width = st->codec.width; width = st->codec->width;
height = st->codec.height; height = st->codec->height;
packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
if (packet_size < 0) if (packet_size < 0)
return -1; return -1;

View File

@ -298,7 +298,7 @@ static int rm_write_header(AVFormatContext *s)
for(n=0;n<s->nb_streams;n++) { for(n=0;n<s->nb_streams;n++) {
s->streams[n]->id = n; s->streams[n]->id = n;
codec = &s->streams[n]->codec; codec = s->streams[n]->codec;
stream = &rm->streams[n]; stream = &rm->streams[n];
memset(stream, 0, sizeof(StreamInfo)); memset(stream, 0, sizeof(StreamInfo));
stream->num = n; stream->num = n;
@ -399,7 +399,7 @@ static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int
static int rm_write_packet(AVFormatContext *s, AVPacket *pkt) static int rm_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
if (s->streams[pkt->stream_index]->codec.codec_type == if (s->streams[pkt->stream_index]->codec->codec_type ==
CODEC_TYPE_AUDIO) CODEC_TYPE_AUDIO)
return rm_write_audio(s, pkt->data, pkt->size, pkt->flags); return rm_write_audio(s, pkt->data, pkt->size, pkt->flags);
else else
@ -495,10 +495,10 @@ static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
get_str8(pb, s->comment, sizeof(s->comment)); get_str8(pb, s->comment, sizeof(s->comment));
get_byte(pb); get_byte(pb);
get_str8(pb, buf, sizeof(buf)); get_str8(pb, buf, sizeof(buf));
st->codec.sample_rate = 8000; st->codec->sample_rate = 8000;
st->codec.channels = 1; st->codec->channels = 1;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_RA_144; st->codec->codec_id = CODEC_ID_RA_144;
} else { } else {
int flavor, sub_packet_h, coded_framesize; int flavor, sub_packet_h, coded_framesize;
/* old version (4) */ /* old version (4) */
@ -512,30 +512,30 @@ static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st,
get_be32(pb); /* ??? */ get_be32(pb); /* ??? */
get_be32(pb); /* ??? */ get_be32(pb); /* ??? */
sub_packet_h= get_be16(pb); /* 1 */ sub_packet_h= get_be16(pb); /* 1 */
st->codec.block_align= get_be16(pb); /* frame size */ st->codec->block_align= get_be16(pb); /* frame size */
get_be16(pb); /* sub packet size */ get_be16(pb); /* sub packet size */
get_be16(pb); /* ??? */ get_be16(pb); /* ??? */
st->codec.sample_rate = get_be16(pb); st->codec->sample_rate = get_be16(pb);
get_be32(pb); get_be32(pb);
st->codec.channels = get_be16(pb); st->codec->channels = get_be16(pb);
get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, buf, sizeof(buf)); /* desc */
get_str8(pb, buf, sizeof(buf)); /* desc */ get_str8(pb, buf, sizeof(buf)); /* desc */
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
if (!strcmp(buf, "dnet")) { if (!strcmp(buf, "dnet")) {
st->codec.codec_id = CODEC_ID_AC3; st->codec->codec_id = CODEC_ID_AC3;
} else if (!strcmp(buf, "28_8")) { } else if (!strcmp(buf, "28_8")) {
st->codec.codec_id = CODEC_ID_RA_288; st->codec->codec_id = CODEC_ID_RA_288;
st->codec.extradata_size= 10; st->codec->extradata_size= 10;
st->codec.extradata= av_mallocz(st->codec.extradata_size); st->codec->extradata= av_mallocz(st->codec->extradata_size);
/* this is completly braindead and broken, the idiot who added this codec and endianness /* this is completly braindead and broken, the idiot who added this codec and endianness
specific reordering to mplayer and libavcodec/ra288.c should be drowned in a see of cola */ specific reordering to mplayer and libavcodec/ra288.c should be drowned in a see of cola */
//FIXME pass the unpermutated extradata //FIXME pass the unpermutated extradata
((uint16_t*)st->codec.extradata)[1]= sub_packet_h; ((uint16_t*)st->codec->extradata)[1]= sub_packet_h;
((uint16_t*)st->codec.extradata)[2]= flavor; ((uint16_t*)st->codec->extradata)[2]= flavor;
((uint16_t*)st->codec.extradata)[3]= coded_framesize; ((uint16_t*)st->codec->extradata)[3]= coded_framesize;
} else { } else {
st->codec.codec_id = CODEC_ID_NONE; st->codec->codec_id = CODEC_ID_NONE;
pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name), pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name),
buf); buf);
} }
if (read_all) { if (read_all) {
@ -635,7 +635,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
goto fail; goto fail;
st->id = get_be16(pb); st->id = get_be16(pb);
get_be32(pb); /* max bit rate */ get_be32(pb); /* max bit rate */
st->codec.bit_rate = get_be32(pb); /* bit rate */ st->codec->bit_rate = get_be32(pb); /* bit rate */
get_be32(pb); /* max packet size */ get_be32(pb); /* max packet size */
get_be32(pb); /* avg packet size */ get_be32(pb); /* avg packet size */
start_time = get_be32(pb); /* start time */ start_time = get_be32(pb); /* start time */
@ -647,7 +647,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_str8(pb, buf, sizeof(buf)); /* mimetype */ get_str8(pb, buf, sizeof(buf)); /* mimetype */
codec_data_size = get_be32(pb); codec_data_size = get_be32(pb);
codec_pos = url_ftell(pb); codec_pos = url_ftell(pb);
st->codec.codec_type = CODEC_TYPE_DATA; st->codec->codec_type = CODEC_TYPE_DATA;
av_set_pts_info(st, 64, 1, 1000); av_set_pts_info(st, 64, 1, 1000);
v = get_be32(pb); v = get_be32(pb);
@ -658,43 +658,43 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
int fps, fps2; int fps, fps2;
if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
fail1: fail1:
av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
goto skip; goto skip;
} }
st->codec.codec_tag = get_le32(pb); st->codec->codec_tag = get_le32(pb);
// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec.codec_tag, MKTAG('R', 'V', '2', '0')); // av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0'));
if ( st->codec.codec_tag != MKTAG('R', 'V', '1', '0') if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0')
&& st->codec.codec_tag != MKTAG('R', 'V', '2', '0') && st->codec->codec_tag != MKTAG('R', 'V', '2', '0')
&& st->codec.codec_tag != MKTAG('R', 'V', '3', '0') && st->codec->codec_tag != MKTAG('R', 'V', '3', '0')
&& st->codec.codec_tag != MKTAG('R', 'V', '4', '0')) && st->codec->codec_tag != MKTAG('R', 'V', '4', '0'))
goto fail1; goto fail1;
st->codec.width = get_be16(pb); st->codec->width = get_be16(pb);
st->codec.height = get_be16(pb); st->codec->height = get_be16(pb);
st->codec.time_base.num= 1; st->codec->time_base.num= 1;
fps= get_be16(pb); fps= get_be16(pb);
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
get_be32(pb); get_be32(pb);
fps2= get_be16(pb); fps2= get_be16(pb);
get_be16(pb); get_be16(pb);
st->codec.extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos);
st->codec.extradata= av_malloc(st->codec.extradata_size); st->codec->extradata= av_malloc(st->codec->extradata_size);
get_buffer(pb, st->codec.extradata, st->codec.extradata_size); get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); // av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
st->codec.time_base.den = fps * st->codec.time_base.num; st->codec->time_base.den = fps * st->codec->time_base.num;
/* modification of h263 codec version (!) */ /* modification of h263 codec version (!) */
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
h263_hack_version = ((uint32_t*)st->codec.extradata)[1]; h263_hack_version = ((uint32_t*)st->codec->extradata)[1];
#else #else
h263_hack_version = bswap_32(((uint32_t*)st->codec.extradata)[1]); h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]);
#endif #endif
st->codec.sub_id = h263_hack_version; st->codec->sub_id = h263_hack_version;
switch((h263_hack_version>>28)){ switch((h263_hack_version>>28)){
case 1: st->codec.codec_id = CODEC_ID_RV10; break; case 1: st->codec->codec_id = CODEC_ID_RV10; break;
case 2: st->codec.codec_id = CODEC_ID_RV20; break; case 2: st->codec->codec_id = CODEC_ID_RV20; break;
case 3: st->codec.codec_id = CODEC_ID_RV30; break; case 3: st->codec->codec_id = CODEC_ID_RV30; break;
case 4: st->codec.codec_id = CODEC_ID_RV40; break; case 4: st->codec->codec_id = CODEC_ID_RV40; break;
default: goto fail1; default: goto fail1;
} }
} }
@ -827,7 +827,7 @@ resync:
return AVERROR_IO; return AVERROR_IO;
st = s->streams[i]; st = s->streams[i];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
int h, pic_num, len2, pos; int h, pic_num, len2, pos;
h= get_byte(pb); len--; h= get_byte(pb); len--;
@ -862,8 +862,8 @@ resync:
pkt->stream_index = i; pkt->stream_index = i;
#if 0 #if 0
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->codec.codec_id == CODEC_ID_RV20){ if(st->codec->codec_id == CODEC_ID_RV20){
int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1); int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1);
av_log(NULL, AV_LOG_DEBUG, "%d %Ld %d\n", timestamp, timestamp*512LL/25, seq); av_log(NULL, AV_LOG_DEBUG, "%d %Ld %d\n", timestamp, timestamp*512LL/25, seq);
@ -882,7 +882,7 @@ resync:
} }
/* for AC3, needs to swap bytes */ /* for AC3, needs to swap bytes */
if (st->codec.codec_id == CODEC_ID_AC3) { if (st->codec->codec_id == CODEC_ID_AC3) {
ptr = pkt->data; ptr = pkt->data;
for(j=0;j<len;j+=2) { for(j=0;j<len;j+=2) {
tmp = ptr[0]; tmp = ptr[0];
@ -937,7 +937,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index,
return AV_NOPTS_VALUE; return AV_NOPTS_VALUE;
st = s->streams[stream_index2]; st = s->streams[stream_index2];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
h= get_byte(&s->pb); len--; h= get_byte(&s->pb); len--;
if(!(h & 0x40)){ if(!(h & 0x40)){
seq = get_byte(&s->pb); len--; seq = get_byte(&s->pb); len--;

View File

@ -290,7 +290,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_t
return NULL; return NULL;
} }
} else { } else {
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG1VIDEO:
case CODEC_ID_MPEG2VIDEO: case CODEC_ID_MPEG2VIDEO:
case CODEC_ID_MP2: case CODEC_ID_MP2:
@ -307,7 +307,6 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_t
static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf) static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf)
{ {
AVCodecContext codec;
int au_headers_length, au_header_size, i; int au_headers_length, au_header_size, i;
GetBitContext getbitcontext; GetBitContext getbitcontext;
rtp_payload_data_t *infos; rtp_payload_data_t *infos;
@ -317,8 +316,6 @@ static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf)
if (infos == NULL) if (infos == NULL)
return -1; return -1;
codec = s->st->codec;
/* decode the first 2 bytes where are stored the AUHeader sections /* decode the first 2 bytes where are stored the AUHeader sections
length in bits */ length in bits */
au_headers_length = BE_16(buf); au_headers_length = BE_16(buf);
@ -407,7 +404,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
return -1; return -1;
#if defined(DEBUG) || 1 #if defined(DEBUG) || 1
if (seq != ((s->seq + 1) & 0xffff)) { if (seq != ((s->seq + 1) & 0xffff)) {
av_log(&s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", av_log(s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff)); payload_type, seq, ((s->seq + 1) & 0xffff));
} }
#endif #endif
@ -428,7 +425,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
return 1; return 1;
} }
} else { } else {
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MP2: case CODEC_ID_MP2:
/* better than nothing: skip mpeg audio RTP header */ /* better than nothing: skip mpeg audio RTP header */
if (len <= 4) if (len <= 4)
@ -462,7 +459,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
break; break;
} }
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MP2: case CODEC_ID_MP2:
case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG1VIDEO:
if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
@ -529,7 +526,7 @@ static int rtp_write_header(AVFormatContext *s1)
return -1; return -1;
st = s1->streams[0]; st = s1->streams[0];
payload_type = rtp_get_payload_type(&st->codec); payload_type = rtp_get_payload_type(st->codec);
if (payload_type < 0) if (payload_type < 0)
payload_type = RTP_PT_PRIVATE; /* private payload type */ payload_type = RTP_PT_PRIVATE; /* private payload type */
s->payload_type = payload_type; s->payload_type = payload_type;
@ -544,7 +541,7 @@ static int rtp_write_header(AVFormatContext *s1)
return AVERROR_IO; return AVERROR_IO;
s->max_payload_size = max_packet_size - 12; s->max_payload_size = max_packet_size - 12;
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MP2: case CODEC_ID_MP2:
case CODEC_ID_MP3: case CODEC_ID_MP3:
s->buf_ptr = s->buf + 4; s->buf_ptr = s->buf + 4;
@ -663,7 +660,7 @@ static void rtp_send_mpegaudio(AVFormatContext *s1,
s->buf_ptr = s->buf + 4; s->buf_ptr = s->buf + 4;
/* 90 KHz time stamp */ /* 90 KHz time stamp */
s->timestamp = s->base_timestamp + s->timestamp = s->base_timestamp +
(s->cur_timestamp * 90000LL) / st->codec.sample_rate; (s->cur_timestamp * 90000LL) / st->codec->sample_rate;
} }
} }
@ -697,7 +694,7 @@ static void rtp_send_mpegaudio(AVFormatContext *s1,
memcpy(s->buf_ptr, buf1, size); memcpy(s->buf_ptr, buf1, size);
s->buf_ptr += size; s->buf_ptr += size;
} }
s->cur_timestamp += st->codec.frame_size; s->cur_timestamp += st->codec->frame_size;
} }
/* NOTE: a single frame must be passed with sequence header if /* NOTE: a single frame must be passed with sequence header if
@ -715,7 +712,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1,
while (size > 0) { while (size > 0) {
/* XXX: more correct headers */ /* XXX: more correct headers */
h = 0; h = 0;
if (st->codec.sub_id == 2) if (st->codec->sub_id == 2)
h |= 1 << 26; /* mpeg 2 indicator */ h |= 1 << 26; /* mpeg 2 indicator */
q = s->buf; q = s->buf;
*q++ = h >> 24; *q++ = h >> 24;
@ -723,7 +720,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1,
*q++ = h >> 8; *q++ = h >> 8;
*q++ = h; *q++ = h;
if (st->codec.sub_id == 2) { if (st->codec->sub_id == 2) {
h = 0; h = 0;
*q++ = h >> 24; *q++ = h >> 24;
*q++ = h >> 16; *q++ = h >> 16;
@ -740,7 +737,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1,
/* 90 KHz time stamp */ /* 90 KHz time stamp */
s->timestamp = s->base_timestamp + s->timestamp = s->base_timestamp +
av_rescale((int64_t)s->cur_timestamp * st->codec.time_base.num, 90000, st->codec.time_base.den); //FIXME pass timestamps av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps
rtp_send_data(s1, s->buf, q - s->buf); rtp_send_data(s1, s->buf, q - s->buf);
buf1 += len; buf1 += len;
@ -765,7 +762,7 @@ static void rtp_send_raw(AVFormatContext *s1,
/* 90 KHz time stamp */ /* 90 KHz time stamp */
s->timestamp = s->base_timestamp + s->timestamp = s->base_timestamp +
av_rescale((int64_t)s->cur_timestamp * st->codec.time_base.num, 90000, st->codec.time_base.den); //FIXME pass timestamps av_rescale((int64_t)s->cur_timestamp * st->codec->time_base.num, 90000, st->codec->time_base.den); //FIXME pass timestamps
rtp_send_data(s1, buf1, len); rtp_send_data(s1, buf1, len);
buf1 += len; buf1 += len;
@ -824,18 +821,18 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
s->first_packet = 0; s->first_packet = 0;
} }
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_MULAW:
case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_ALAW:
case CODEC_ID_PCM_U8: case CODEC_ID_PCM_U8:
case CODEC_ID_PCM_S8: case CODEC_ID_PCM_S8:
rtp_send_samples(s1, buf1, size, 1 * st->codec.channels); rtp_send_samples(s1, buf1, size, 1 * st->codec->channels);
break; break;
case CODEC_ID_PCM_U16BE: case CODEC_ID_PCM_U16BE:
case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16LE:
case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16LE:
rtp_send_samples(s1, buf1, size, 2 * st->codec.channels); rtp_send_samples(s1, buf1, size, 2 * st->codec->channels);
break; break;
case CODEC_ID_MP2: case CODEC_ID_MP2:
case CODEC_ID_MP3: case CODEC_ID_MP3:

View File

@ -282,7 +282,7 @@ static void sdp_parse_fmtp(AVStream *st, const char *p)
int i; int i;
RTSPStream *rtsp_st = st->priv_data; RTSPStream *rtsp_st = st->priv_data;
AVCodecContext *codec = &st->codec; AVCodecContext *codec = st->codec;
rtp_payload_data_t *rtp_payload_data = &rtsp_st->rtp_payload_data; rtp_payload_data_t *rtp_payload_data = &rtsp_st->rtp_payload_data;
/* loop on each attribute */ /* loop on each attribute */
@ -405,10 +405,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
return; return;
st->priv_data = rtsp_st; st->priv_data = rtsp_st;
rtsp_st->stream_index = st->index; rtsp_st->stream_index = st->index;
st->codec.codec_type = codec_type; st->codec->codec_type = codec_type;
if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) {
/* if standard payload type, we can find the codec right now */ /* if standard payload type, we can find the codec right now */
rtp_get_codec_info(&st->codec, rtsp_st->sdp_payload_type); rtp_get_codec_info(st->codec, rtsp_st->sdp_payload_type);
} }
} }
/* put a default control url */ /* put a default control url */
@ -438,7 +438,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
st = s->streams[i]; st = s->streams[i];
rtsp_st = st->priv_data; rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) { if (rtsp_st->sdp_payload_type == payload_type) {
sdp_parse_rtpmap(&st->codec, payload_type, p); sdp_parse_rtpmap(st->codec, payload_type, p);
} }
} }
} else if (strstart(p, "fmtp:", &p)) { } else if (strstart(p, "fmtp:", &p)) {

View File

@ -140,11 +140,11 @@ static int film_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
film->video_stream_index = st->index; film->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = film->video_type; st->codec->codec_id = film->video_type;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = BE_32(&scratch[16]); st->codec->width = BE_32(&scratch[16]);
st->codec.height = BE_32(&scratch[12]); st->codec->height = BE_32(&scratch[12]);
} }
if (film->audio_type) { if (film->audio_type) {
@ -152,16 +152,16 @@ static int film_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
film->audio_stream_index = st->index; film->audio_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = film->audio_type; st->codec->codec_id = film->audio_type;
st->codec.codec_tag = 1; st->codec->codec_tag = 1;
st->codec.channels = film->audio_channels; st->codec->channels = film->audio_channels;
st->codec.bits_per_sample = film->audio_bits; st->codec->bits_per_sample = film->audio_bits;
st->codec.sample_rate = film->audio_samplerate; st->codec->sample_rate = film->audio_samplerate;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample; st->codec->bits_per_sample;
st->codec.block_align = st->codec.channels * st->codec->block_align = st->codec->channels *
st->codec.bits_per_sample / 8; st->codec->bits_per_sample / 8;
} }
/* load the sample table */ /* load the sample table */

View File

@ -131,14 +131,14 @@ static int vmd_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
vmd->video_stream_index = st->index; vmd->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_VMDVIDEO; st->codec->codec_id = CODEC_ID_VMDVIDEO;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = LE_16(&vmd->vmd_header[12]); st->codec->width = LE_16(&vmd->vmd_header[12]);
st->codec.height = LE_16(&vmd->vmd_header[14]); st->codec->height = LE_16(&vmd->vmd_header[14]);
st->codec.extradata_size = VMD_HEADER_SIZE; st->codec->extradata_size = VMD_HEADER_SIZE;
st->codec.extradata = av_malloc(VMD_HEADER_SIZE); st->codec->extradata = av_malloc(VMD_HEADER_SIZE);
memcpy(st->codec.extradata, vmd->vmd_header, VMD_HEADER_SIZE); memcpy(st->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE);
/* if sample rate is 0, assume no audio */ /* if sample rate is 0, assume no audio */
vmd->sample_rate = LE_16(&vmd->vmd_header[804]); vmd->sample_rate = LE_16(&vmd->vmd_header[804]);
@ -148,29 +148,29 @@ static int vmd_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
vmd->audio_stream_index = st->index; vmd->audio_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_VMDAUDIO; st->codec->codec_id = CODEC_ID_VMDAUDIO;
st->codec.codec_tag = 0; /* no codec tag */ st->codec->codec_tag = 0; /* no codec tag */
st->codec.channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; st->codec->channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1;
st->codec.sample_rate = vmd->sample_rate; st->codec->sample_rate = vmd->sample_rate;
st->codec.block_align = vmd->audio_block_align = st->codec->block_align = vmd->audio_block_align =
LE_16(&vmd->vmd_header[806]); LE_16(&vmd->vmd_header[806]);
if (st->codec.block_align & 0x8000) { if (st->codec->block_align & 0x8000) {
st->codec.bits_per_sample = 16; st->codec->bits_per_sample = 16;
st->codec.block_align = -(st->codec.block_align - 0x10000); st->codec->block_align = -(st->codec->block_align - 0x10000);
} else } else
st->codec.bits_per_sample = 16; st->codec->bits_per_sample = 16;
// st->codec.bits_per_sample = 8; // st->codec->bits_per_sample = 8;
st->codec.bit_rate = st->codec.sample_rate * st->codec->bit_rate = st->codec->sample_rate *
st->codec.bits_per_sample * st->codec.channels; st->codec->bits_per_sample * st->codec->channels;
/* for calculating pts */ /* for calculating pts */
vmd->audio_frame_divisor = st->codec.bits_per_sample / 8 / vmd->audio_frame_divisor = st->codec->bits_per_sample / 8 /
st->codec.channels; st->codec->channels;
video_pts_inc = 90000; video_pts_inc = 90000;
video_pts_inc *= st->codec.block_align; video_pts_inc *= st->codec->block_align;
video_pts_inc /= st->codec.sample_rate; video_pts_inc /= st->codec->sample_rate;
} else { } else {
/* if no audio, assume 10 frames/second */ /* if no audio, assume 10 frames/second */
video_pts_inc = 90000 / 10; video_pts_inc = 90000 / 10;

View File

@ -113,11 +113,11 @@ static int sol_read_header(AVFormatContext *s,
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
return -1; return -1;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_tag = id; st->codec->codec_tag = id;
st->codec.codec_id = codec; st->codec->codec_id = codec;
st->codec.channels = channels; st->codec->channels = channels;
st->codec.sample_rate = rate; st->codec->sample_rate = rate;
av_set_pts_info(st, 64, 1, rate); av_set_pts_info(st, 64, 1, rate);
return 0; return 0;
} }

View File

@ -324,7 +324,7 @@ static int swf_write_header(AVFormatContext *s)
video_enc = NULL; video_enc = NULL;
audio_enc = NULL; audio_enc = NULL;
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
enc = &s->streams[i]->codec; enc = s->streams[i]->codec;
if (enc->codec_type == CODEC_TYPE_AUDIO) if (enc->codec_type == CODEC_TYPE_AUDIO)
audio_enc = enc; audio_enc = enc;
else { else {
@ -652,7 +652,7 @@ static int swf_write_audio(AVFormatContext *s,
static int swf_write_packet(AVFormatContext *s, AVPacket *pkt) static int swf_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
AVCodecContext *codec = &s->streams[pkt->stream_index]->codec; AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
if (codec->codec_type == CODEC_TYPE_AUDIO) if (codec->codec_type == CODEC_TYPE_AUDIO)
return swf_write_audio(s, codec, pkt->data, pkt->size); return swf_write_audio(s, codec, pkt->data, pkt->size);
else else
@ -668,7 +668,7 @@ static int swf_write_trailer(AVFormatContext *s)
video_enc = NULL; video_enc = NULL;
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
enc = &s->streams[i]->codec; enc = s->streams[i]->codec;
if (enc->codec_type == CODEC_TYPE_VIDEO) if (enc->codec_type == CODEC_TYPE_VIDEO)
video_enc = enc; video_enc = enc;
} }
@ -775,8 +775,8 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
if (tag < 0) { if (tag < 0) {
if ( ast || vst ) { if ( ast || vst ) {
if ( vst && ast ) { if ( vst && ast ) {
vst->codec.time_base.den = ast->codec.sample_rate / swf->samples_per_frame; vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame;
vst->codec.time_base.num = 1; vst->codec->time_base.num = 1;
} }
break; break;
} }
@ -794,11 +794,11 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
vst = av_new_stream(s, 0); vst = av_new_stream(s, 0);
av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */ av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */
vst->codec.codec_type = CODEC_TYPE_VIDEO; vst->codec->codec_type = CODEC_TYPE_VIDEO;
vst->codec.codec_id = CODEC_ID_FLV1; vst->codec->codec_id = CODEC_ID_FLV1;
if ( swf->samples_per_frame ) { if ( swf->samples_per_frame ) {
vst->codec.time_base.den = 1000. / swf->ms_per_frame; vst->codec->time_base.den = 1000. / swf->ms_per_frame;
vst->codec.time_base.num = 1; vst->codec->time_base.num = 1;
} }
} }
} else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) { } else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) {
@ -819,26 +819,26 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
return -ENOMEM; return -ENOMEM;
if (v & 0x01) if (v & 0x01)
ast->codec.channels = 2; ast->codec->channels = 2;
else else
ast->codec.channels = 1; ast->codec->channels = 1;
switch((v>> 2) & 0x03) { switch((v>> 2) & 0x03) {
case 1: case 1:
ast->codec.sample_rate = 11025; ast->codec->sample_rate = 11025;
break; break;
case 2: case 2:
ast->codec.sample_rate = 22050; ast->codec->sample_rate = 22050;
break; break;
case 3: case 3:
ast->codec.sample_rate = 44100; ast->codec->sample_rate = 44100;
break; break;
default: default:
av_free(ast); av_free(ast);
return AVERROR_IO; return AVERROR_IO;
} }
ast->codec.codec_type = CODEC_TYPE_AUDIO; ast->codec->codec_type = CODEC_TYPE_AUDIO;
ast->codec.codec_id = CODEC_ID_MP3; ast->codec->codec_id = CODEC_ID_MP3;
} }
} else { } else {
url_fskip(pb, len); url_fskip(pb, len);

View File

@ -683,14 +683,14 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st,
*pnum = 0; *pnum = 0;
*pden = 0; *pden = 0;
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
if(st->time_base.num*1000LL > st->time_base.den){ if(st->time_base.num*1000LL > st->time_base.den){
*pnum = st->time_base.num; *pnum = st->time_base.num;
*pden = st->time_base.den; *pden = st->time_base.den;
}else if(st->codec.time_base.num*1000LL > st->codec.time_base.den){ }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){
*pnum = st->codec.time_base.num; *pnum = st->codec->time_base.num;
*pden = st->codec.time_base.den; *pden = st->codec->time_base.den;
if (pc && pc->repeat_pict) { if (pc && pc->repeat_pict) {
*pden *= 2; *pden *= 2;
*pnum = (*pnum) * (2 + pc->repeat_pict); *pnum = (*pnum) * (2 + pc->repeat_pict);
@ -698,11 +698,11 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st,
} }
break; break;
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
frame_size = get_audio_frame_size(&st->codec, pkt->size); frame_size = get_audio_frame_size(st->codec, pkt->size);
if (frame_size < 0) if (frame_size < 0)
break; break;
*pnum = frame_size; *pnum = frame_size;
*pden = st->codec.sample_rate; *pden = st->codec->sample_rate;
break; break;
default: default:
break; break;
@ -756,16 +756,16 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
} }
} }
if(is_intra_only(&st->codec)) if(is_intra_only(st->codec))
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
/* do we have a video B frame ? */ /* do we have a video B frame ? */
presentation_delayed = 0; presentation_delayed = 0;
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
/* XXX: need has_b_frame, but cannot get it if the codec is /* XXX: need has_b_frame, but cannot get it if the codec is
not initialized */ not initialized */
if (( st->codec.codec_id == CODEC_ID_H264 if (( st->codec->codec_id == CODEC_ID_H264
|| st->codec.has_b_frames) && || st->codec->has_b_frames) &&
pc && pc->pict_type != FF_B_TYPE) pc && pc->pict_type != FF_B_TYPE)
presentation_delayed = 1; presentation_delayed = 1;
/* this may be redundant, but it shouldnt hurt */ /* this may be redundant, but it shouldnt hurt */
@ -834,7 +834,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st,
if (pc) { if (pc) {
pkt->flags = 0; pkt->flags = 0;
/* key frame computation */ /* key frame computation */
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
if (pc->pict_type == FF_I_TYPE) if (pc->pict_type == FF_I_TYPE)
pkt->flags |= PKT_FLAG_KEY; pkt->flags |= PKT_FLAG_KEY;
@ -870,7 +870,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
s->cur_st = NULL; s->cur_st = NULL;
return 0; return 0;
} else if (s->cur_len > 0 && st->discard < AVDISCARD_ALL) { } else if (s->cur_len > 0 && st->discard < AVDISCARD_ALL) {
len = av_parser_parse(st->parser, &st->codec, &pkt->data, &pkt->size, len = av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size,
s->cur_ptr, s->cur_len, s->cur_ptr, s->cur_len,
s->cur_pkt.pts, s->cur_pkt.dts); s->cur_pkt.pts, s->cur_pkt.dts);
s->cur_pkt.pts = AV_NOPTS_VALUE; s->cur_pkt.pts = AV_NOPTS_VALUE;
@ -905,7 +905,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
for(i = 0; i < s->nb_streams; i++) { for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i]; st = s->streams[i];
if (st->parser && st->need_parsing) { if (st->parser && st->need_parsing) {
av_parser_parse(st->parser, &st->codec, av_parser_parse(st->parser, st->codec,
&pkt->data, &pkt->size, &pkt->data, &pkt->size,
NULL, 0, NULL, 0,
AV_NOPTS_VALUE, AV_NOPTS_VALUE); AV_NOPTS_VALUE, AV_NOPTS_VALUE);
@ -923,7 +923,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
s->cur_ptr = s->cur_pkt.data; s->cur_ptr = s->cur_pkt.data;
s->cur_len = s->cur_pkt.size; s->cur_len = s->cur_pkt.size;
if (st->need_parsing && !st->parser) { if (st->need_parsing && !st->parser) {
st->parser = av_parser_init(st->codec.codec_id); st->parser = av_parser_init(st->codec->codec_id);
if (!st->parser) { if (!st->parser) {
/* no parser available : just output the raw packets */ /* no parser available : just output the raw packets */
st->need_parsing = 0; st->need_parsing = 0;
@ -995,7 +995,7 @@ int av_find_default_stream_index(AVFormatContext *s)
return -1; return -1;
for(i = 0; i < s->nb_streams; i++) { for(i = 0; i < s->nb_streams; i++) {
st = s->streams[i]; st = s->streams[i];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
return i; return i;
} }
} }
@ -1537,7 +1537,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic)
bit_rate = 0; bit_rate = 0;
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
bit_rate += st->codec.bit_rate; bit_rate += st->codec->bit_rate;
} }
ic->bit_rate = bit_rate; ic->bit_rate = bit_rate;
} }
@ -1728,26 +1728,26 @@ static int try_decode_frame(AVStream *st, const uint8_t *data, int size)
int got_picture, ret=0; int got_picture, ret=0;
AVFrame picture; AVFrame picture;
if(!st->codec.codec){ if(!st->codec->codec){
codec = avcodec_find_decoder(st->codec.codec_id); codec = avcodec_find_decoder(st->codec->codec_id);
if (!codec) if (!codec)
return -1; return -1;
ret = avcodec_open(&st->codec, codec); ret = avcodec_open(st->codec, codec);
if (ret < 0) if (ret < 0)
return ret; return ret;
} }
if(!has_codec_parameters(&st->codec)){ if(!has_codec_parameters(st->codec)){
switch(st->codec.codec_type) { switch(st->codec->codec_type) {
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
ret = avcodec_decode_video(&st->codec, &picture, ret = avcodec_decode_video(st->codec, &picture,
&got_picture, (uint8_t *)data, size); &got_picture, (uint8_t *)data, size);
break; break;
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE);
if (!samples) if (!samples)
goto fail; goto fail;
ret = avcodec_decode_audio(&st->codec, samples, ret = avcodec_decode_audio(st->codec, samples,
&got_picture, (uint8_t *)data, size); &got_picture, (uint8_t *)data, size);
av_free(samples); av_free(samples);
break; break;
@ -1787,15 +1787,15 @@ int av_find_stream_info(AVFormatContext *ic)
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if(st->codec.codec_type == CODEC_TYPE_VIDEO){ if(st->codec->codec_type == CODEC_TYPE_VIDEO){
/* if(!st->time_base.num) /* if(!st->time_base.num)
st->time_base= */ st->time_base= */
if(!st->codec.time_base.num) if(!st->codec->time_base.num)
st->codec.time_base= st->time_base; st->codec->time_base= st->time_base;
} }
//only for the split stuff //only for the split stuff
if (!st->parser) { if (!st->parser) {
st->parser = av_parser_init(st->codec.codec_id); st->parser = av_parser_init(st->codec->codec_id);
} }
} }
@ -1811,13 +1811,13 @@ int av_find_stream_info(AVFormatContext *ic)
/* check if one codec still needs to be handled */ /* check if one codec still needs to be handled */
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if (!has_codec_parameters(&st->codec)) if (!has_codec_parameters(st->codec))
break; break;
/* variable fps and no guess at the real fps */ /* variable fps and no guess at the real fps */
if( st->codec.time_base.den >= 1000LL*st->codec.time_base.num if( st->codec->time_base.den >= 1000LL*st->codec->time_base.num
&& duration_count[i]<20 && st->codec.codec_type == CODEC_TYPE_VIDEO) && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO)
break; break;
if(st->parser && st->parser->parser->split && !st->codec.extradata) if(st->parser && st->parser->parser->split && !st->codec->extradata)
break; break;
} }
if (i == ic->nb_streams) { if (i == ic->nb_streams) {
@ -1845,7 +1845,7 @@ int av_find_stream_info(AVFormatContext *ic)
ret = -1; /* we could not have all the codec parameters before EOF */ ret = -1; /* we could not have all the codec parameters before EOF */
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if (!has_codec_parameters(&st->codec)) if (!has_codec_parameters(st->codec))
break; break;
} }
if (i == ic->nb_streams) if (i == ic->nb_streams)
@ -1898,12 +1898,12 @@ int av_find_stream_info(AVFormatContext *ic)
} }
last_dts[pkt->stream_index]= pkt->dts; last_dts[pkt->stream_index]= pkt->dts;
} }
if(st->parser && st->parser->parser->split && !st->codec.extradata){ if(st->parser && st->parser->parser->split && !st->codec->extradata){
int i= st->parser->parser->split(&st->codec, pkt->data, pkt->size); int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
if(i){ if(i){
st->codec.extradata_size= i; st->codec->extradata_size= i;
st->codec.extradata= av_malloc(st->codec.extradata_size); st->codec->extradata= av_malloc(st->codec->extradata_size);
memcpy(st->codec.extradata, pkt->data, st->codec.extradata_size); memcpy(st->codec->extradata, pkt->data, st->codec->extradata_size);
} }
} }
@ -1911,21 +1911,21 @@ int av_find_stream_info(AVFormatContext *ic)
decompress the frame. We try to avoid that in most cases as decompress the frame. We try to avoid that in most cases as
it takes longer and uses more memory. For MPEG4, we need to it takes longer and uses more memory. For MPEG4, we need to
decompress for Quicktime. */ decompress for Quicktime. */
if (!has_codec_parameters(&st->codec) /*&& if (!has_codec_parameters(st->codec) /*&&
(st->codec.codec_id == CODEC_ID_FLV1 || (st->codec->codec_id == CODEC_ID_FLV1 ||
st->codec.codec_id == CODEC_ID_H264 || st->codec->codec_id == CODEC_ID_H264 ||
st->codec.codec_id == CODEC_ID_H263 || st->codec->codec_id == CODEC_ID_H263 ||
st->codec.codec_id == CODEC_ID_H261 || st->codec->codec_id == CODEC_ID_H261 ||
st->codec.codec_id == CODEC_ID_VORBIS || st->codec->codec_id == CODEC_ID_VORBIS ||
st->codec.codec_id == CODEC_ID_MJPEG || st->codec->codec_id == CODEC_ID_MJPEG ||
st->codec.codec_id == CODEC_ID_PNG || st->codec->codec_id == CODEC_ID_PNG ||
st->codec.codec_id == CODEC_ID_PAM || st->codec->codec_id == CODEC_ID_PAM ||
st->codec.codec_id == CODEC_ID_PGM || st->codec->codec_id == CODEC_ID_PGM ||
st->codec.codec_id == CODEC_ID_PGMYUV || st->codec->codec_id == CODEC_ID_PGMYUV ||
st->codec.codec_id == CODEC_ID_PBM || st->codec->codec_id == CODEC_ID_PBM ||
st->codec.codec_id == CODEC_ID_PPM || st->codec->codec_id == CODEC_ID_PPM ||
st->codec.codec_id == CODEC_ID_SHORTEN || st->codec->codec_id == CODEC_ID_SHORTEN ||
(st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/) (st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/)
try_decode_frame(st, pkt->data, pkt->size); try_decode_frame(st, pkt->data, pkt->size);
if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION) { if (av_rescale_q(st->codec_info_duration, st->time_base, AV_TIME_BASE_Q) >= MAX_STREAM_DURATION) {
@ -1937,16 +1937,16 @@ int av_find_stream_info(AVFormatContext *ic)
// close codecs which where opened in try_decode_frame() // close codecs which where opened in try_decode_frame()
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if(st->codec.codec) if(st->codec->codec)
avcodec_close(&st->codec); avcodec_close(st->codec);
} }
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(st->codec.codec_id == CODEC_ID_RAWVIDEO && !st->codec.codec_tag && !st->codec.bits_per_sample) if(st->codec->codec_id == CODEC_ID_RAWVIDEO && !st->codec->codec_tag && !st->codec->bits_per_sample)
st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt); st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt);
if(duration_count[i] && st->codec.time_base.num*1000LL <= st->codec.time_base.den && if(duration_count[i] && st->codec->time_base.num*1000LL <= st->codec->time_base.den &&
st->time_base.num*duration_sum[i]/duration_count[i]*1000LL > st->time_base.den){ st->time_base.num*duration_sum[i]/duration_count[i]*1000LL > st->time_base.den){
AVRational fps1; AVRational fps1;
int64_t num, den; int64_t num, den;
@ -1964,14 +1964,14 @@ int av_find_stream_info(AVFormatContext *ic)
/* set real frame rate info */ /* set real frame rate info */
/* compute the real frame rate for telecine */ /* compute the real frame rate for telecine */
if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO || if ((st->codec->codec_id == CODEC_ID_MPEG1VIDEO ||
st->codec.codec_id == CODEC_ID_MPEG2VIDEO) && st->codec->codec_id == CODEC_ID_MPEG2VIDEO) &&
st->codec.sub_id == 2) { st->codec->sub_id == 2) {
if (st->codec_info_nb_frames >= 20) { if (st->codec_info_nb_frames >= 20) {
float coded_frame_rate, est_frame_rate; float coded_frame_rate, est_frame_rate;
est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) /
(double)st->codec_info_duration ; (double)st->codec_info_duration ;
coded_frame_rate = 1.0/av_q2d(st->codec.time_base); coded_frame_rate = 1.0/av_q2d(st->codec->time_base);
#if 0 #if 0
printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n",
coded_frame_rate, est_frame_rate); coded_frame_rate, est_frame_rate);
@ -1987,8 +1987,8 @@ int av_find_stream_info(AVFormatContext *ic)
} }
/* if no real frame rate, use the codec one */ /* if no real frame rate, use the codec one */
if (!st->r_frame_rate.num){ if (!st->r_frame_rate.num){
st->r_frame_rate.num = st->codec.time_base.den; st->r_frame_rate.num = st->codec->time_base.den;
st->r_frame_rate.den = st->codec.time_base.num; st->r_frame_rate.den = st->codec->time_base.num;
} }
} }
} }
@ -1998,7 +1998,7 @@ int av_find_stream_info(AVFormatContext *ic)
/* correct DTS for b frame streams with no timestamps */ /* correct DTS for b frame streams with no timestamps */
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i]; st = ic->streams[i];
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
if(b-frames){ if(b-frames){
ppktl = &ic->packet_buffer; ppktl = &ic->packet_buffer;
while(ppkt1){ while(ppkt1){
@ -2069,6 +2069,7 @@ void av_close_input_file(AVFormatContext *s)
av_parser_close(st->parser); av_parser_close(st->parser);
} }
av_free(st->index_entries); av_free(st->index_entries);
av_free(st->codec);
av_free(st); av_free(st);
} }
flush_packet_queue(s); flush_packet_queue(s);
@ -2103,10 +2104,11 @@ AVStream *av_new_stream(AVFormatContext *s, int id)
st = av_mallocz(sizeof(AVStream)); st = av_mallocz(sizeof(AVStream));
if (!st) if (!st)
return NULL; return NULL;
avcodec_get_context_defaults(&st->codec);
st->codec= avcodec_alloc_context();
if (s->iformat) { if (s->iformat) {
/* no default bitrate if decoding */ /* no default bitrate if decoding */
st->codec.bit_rate = 0; st->codec->bit_rate = 0;
} }
st->index = s->nb_streams; st->index = s->nb_streams;
st->id = id; st->id = id;
@ -2164,14 +2166,14 @@ int av_write_header(AVFormatContext *s)
for(i=0;i<s->nb_streams;i++) { for(i=0;i<s->nb_streams;i++) {
st = s->streams[i]; st = s->streams[i];
switch (st->codec.codec_type) { switch (st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
av_frac_init(&st->pts, 0, 0, av_frac_init(&st->pts, 0, 0,
(int64_t)st->time_base.num * st->codec.sample_rate); (int64_t)st->time_base.num * st->codec->sample_rate);
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
av_frac_init(&st->pts, 0, 0, av_frac_init(&st->pts, 0, 0,
(int64_t)st->time_base.num * st->codec.time_base.den); (int64_t)st->time_base.num * st->codec->time_base.den);
break; break;
default: default:
break; break;
@ -2182,7 +2184,7 @@ int av_write_header(AVFormatContext *s)
//FIXME merge with compute_pkt_fields //FIXME merge with compute_pkt_fields
static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){
int b_frames = FFMAX(st->codec.has_b_frames, st->codec.max_b_frames); int b_frames = FFMAX(st->codec->has_b_frames, st->codec->max_b_frames);
int num, den, frame_size; int num, den, frame_size;
// av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts:%lld dts:%lld cur_dts:%lld b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, b_frames, pkt->size, pkt->stream_index); // av_log(NULL, AV_LOG_DEBUG, "av_write_frame: pts:%lld dts:%lld cur_dts:%lld b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, b_frames, pkt->size, pkt->stream_index);
@ -2234,9 +2236,9 @@ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){
st->pts.val= pkt->dts; st->pts.val= pkt->dts;
/* update pts */ /* update pts */
switch (st->codec.codec_type) { switch (st->codec->codec_type) {
case CODEC_TYPE_AUDIO: case CODEC_TYPE_AUDIO:
frame_size = get_audio_frame_size(&st->codec, pkt->size); frame_size = get_audio_frame_size(st->codec, pkt->size);
/* HACK/FIXME, we skip the initial 0-size packets as they are most likely equal to the encoder delay, /* HACK/FIXME, we skip the initial 0-size packets as they are most likely equal to the encoder delay,
but it would be better if we had the real timestamps from the encoder */ but it would be better if we had the real timestamps from the encoder */
@ -2245,7 +2247,7 @@ static int compute_pkt_fields2(AVStream *st, AVPacket *pkt){
} }
break; break;
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec.time_base.num); av_frac_add(&st->pts, (int64_t)st->time_base.den * st->codec->time_base.num);
break; break;
default: default:
break; break;
@ -2380,7 +2382,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){
AVStream *st= s->streams[ pkt->stream_index]; AVStream *st= s->streams[ pkt->stream_index];
//FIXME/XXX/HACK drop zero sized packets //FIXME/XXX/HACK drop zero sized packets
if(st->codec.codec_type == CODEC_TYPE_AUDIO && pkt->size==0) if(st->codec->codec_type == CODEC_TYPE_AUDIO && pkt->size==0)
return 0; return 0;
//av_log(NULL, AV_LOG_DEBUG, "av_interleaved_write_frame %d %Ld %Ld\n", pkt->size, pkt->dts, pkt->pts); //av_log(NULL, AV_LOG_DEBUG, "av_interleaved_write_frame %d %Ld %Ld\n", pkt->size, pkt->dts, pkt->pts);
@ -2497,7 +2499,7 @@ void dump_format(AVFormatContext *ic,
} }
for(i=0;i<ic->nb_streams;i++) { for(i=0;i<ic->nb_streams;i++) {
AVStream *st = ic->streams[i]; AVStream *st = ic->streams[i];
avcodec_string(buf, sizeof(buf), &st->codec, is_output); avcodec_string(buf, sizeof(buf), st->codec, is_output);
av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i); av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i);
/* the pid is an important information, so we display it */ /* the pid is an important information, so we display it */
/* XXX: add a generic system */ /* XXX: add a generic system */

View File

@ -199,13 +199,13 @@ static int wav_write_header(AVFormatContext *s)
/* format header */ /* format header */
fmt = start_tag(pb, "fmt "); fmt = start_tag(pb, "fmt ");
if (put_wav_header(pb, &s->streams[0]->codec) < 0) { if (put_wav_header(pb, s->streams[0]->codec) < 0) {
av_free(wav); av_free(wav);
return -1; return -1;
} }
end_tag(pb, fmt); end_tag(pb, fmt);
av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec.sample_rate); av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
/* data header */ /* data header */
wav->data = start_tag(pb, "data"); wav->data = start_tag(pb, "data");
@ -305,10 +305,10 @@ static int wav_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
get_wav_header(pb, &st->codec, size); get_wav_header(pb, st->codec, size);
st->need_parsing = 1; st->need_parsing = 1;
av_set_pts_info(st, 64, 1, st->codec.sample_rate); av_set_pts_info(st, 64, 1, st->codec->sample_rate);
size = find_tag(pb, MKTAG('d', 'a', 't', 'a')); size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
if (size < 0) if (size < 0)
@ -329,10 +329,10 @@ static int wav_read_packet(AVFormatContext *s,
st = s->streams[0]; st = s->streams[0];
size = MAX_SIZE; size = MAX_SIZE;
if (st->codec.block_align > 1) { if (st->codec->block_align > 1) {
if (size < st->codec.block_align) if (size < st->codec->block_align)
size = st->codec.block_align; size = st->codec->block_align;
size = (size / st->codec.block_align) * st->codec.block_align; size = (size / st->codec->block_align) * st->codec->block_align;
} }
if (av_new_packet(pkt, size)) if (av_new_packet(pkt, size))
return AVERROR_IO; return AVERROR_IO;
@ -358,7 +358,7 @@ static int wav_read_seek(AVFormatContext *s,
AVStream *st; AVStream *st;
st = s->streams[0]; st = s->streams[0];
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_MP2: case CODEC_ID_MP2:
case CODEC_ID_MP3: case CODEC_ID_MP3:
case CODEC_ID_AC3: case CODEC_ID_AC3:

View File

@ -239,29 +239,29 @@ static int wc3_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
wc3->video_stream_index = st->index; wc3->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_XAN_WC3; st->codec->codec_id = CODEC_ID_XAN_WC3;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
st->codec.width = wc3->width; st->codec->width = wc3->width;
st->codec.height = wc3->height; st->codec->height = wc3->height;
/* palette considerations */ /* palette considerations */
st->codec.palctrl = &wc3->palette_control; st->codec->palctrl = &wc3->palette_control;
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
wc3->audio_stream_index = st->index; wc3->audio_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_PCM_S16LE; st->codec->codec_id = CODEC_ID_PCM_S16LE;
st->codec.codec_tag = 1; st->codec->codec_tag = 1;
st->codec.channels = WC3_AUDIO_CHANNELS; st->codec->channels = WC3_AUDIO_CHANNELS;
st->codec.bits_per_sample = WC3_AUDIO_BITS; st->codec->bits_per_sample = WC3_AUDIO_BITS;
st->codec.sample_rate = WC3_SAMPLE_RATE; st->codec->sample_rate = WC3_SAMPLE_RATE;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample; st->codec->bits_per_sample;
st->codec.block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS; st->codec->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS;
return 0; return 0;
} }

View File

@ -136,15 +136,15 @@ static int wsaud_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, wsaud->audio_samplerate); av_set_pts_info(st, 33, 1, wsaud->audio_samplerate);
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = wsaud->audio_type; st->codec->codec_id = wsaud->audio_type;
st->codec.codec_tag = 0; /* no tag */ st->codec->codec_tag = 0; /* no tag */
st->codec.channels = wsaud->audio_channels; st->codec->channels = wsaud->audio_channels;
st->codec.sample_rate = wsaud->audio_samplerate; st->codec->sample_rate = wsaud->audio_samplerate;
st->codec.bits_per_sample = wsaud->audio_bits; st->codec->bits_per_sample = wsaud->audio_bits;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample / 4; st->codec->bits_per_sample / 4;
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
wsaud->audio_stream_index = st->index; wsaud->audio_stream_index = st->index;
wsaud->audio_frame_counter = 0; wsaud->audio_frame_counter = 0;
@ -222,24 +222,24 @@ static int wsvqa_read_header(AVFormatContext *s,
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
wsvqa->video_stream_index = st->index; wsvqa->video_stream_index = st->index;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_WS_VQA; st->codec->codec_id = CODEC_ID_WS_VQA;
st->codec.codec_tag = 0; /* no fourcc */ st->codec->codec_tag = 0; /* no fourcc */
/* skip to the start of the VQA header */ /* skip to the start of the VQA header */
url_fseek(pb, 20, SEEK_SET); url_fseek(pb, 20, SEEK_SET);
/* the VQA header needs to go to the decoder */ /* the VQA header needs to go to the decoder */
st->codec.extradata_size = VQA_HEADER_SIZE; st->codec->extradata_size = VQA_HEADER_SIZE;
st->codec.extradata = av_malloc(VQA_HEADER_SIZE); st->codec->extradata = av_malloc(VQA_HEADER_SIZE);
header = (unsigned char *)st->codec.extradata; header = (unsigned char *)st->codec->extradata;
if (get_buffer(pb, st->codec.extradata, VQA_HEADER_SIZE) != if (get_buffer(pb, st->codec->extradata, VQA_HEADER_SIZE) !=
VQA_HEADER_SIZE) { VQA_HEADER_SIZE) {
av_free(st->codec.extradata); av_free(st->codec->extradata);
return AVERROR_IO; return AVERROR_IO;
} }
st->codec.width = LE_16(&header[6]); st->codec->width = LE_16(&header[6]);
st->codec.height = LE_16(&header[8]); st->codec->height = LE_16(&header[8]);
/* initialize the audio decoder stream is sample rate is non-zero */ /* initialize the audio decoder stream is sample rate is non-zero */
if (LE_16(&header[24])) { if (LE_16(&header[24])) {
@ -247,19 +247,19 @@ static int wsvqa_read_header(AVFormatContext *s,
if (!st) if (!st)
return AVERROR_NOMEM; return AVERROR_NOMEM;
av_set_pts_info(st, 33, 1, 90000); av_set_pts_info(st, 33, 1, 90000);
st->codec.codec_type = CODEC_TYPE_AUDIO; st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = CODEC_ID_ADPCM_IMA_WS; st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS;
st->codec.codec_tag = 0; /* no tag */ st->codec->codec_tag = 0; /* no tag */
st->codec.sample_rate = LE_16(&header[24]); st->codec->sample_rate = LE_16(&header[24]);
st->codec.channels = header[26]; st->codec->channels = header[26];
st->codec.bits_per_sample = 16; st->codec->bits_per_sample = 16;
st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
st->codec.bits_per_sample / 4; st->codec->bits_per_sample / 4;
st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
wsvqa->audio_stream_index = st->index; wsvqa->audio_stream_index = st->index;
wsvqa->audio_samplerate = st->codec.sample_rate; wsvqa->audio_samplerate = st->codec->sample_rate;
wsvqa->audio_channels = st->codec.channels; wsvqa->audio_channels = st->codec->channels;
wsvqa->audio_frame_counter = 0; wsvqa->audio_frame_counter = 0;
} }
@ -267,7 +267,7 @@ static int wsvqa_read_header(AVFormatContext *s,
* FINF has been skipped and the file will be ready to be demuxed */ * FINF has been skipped and the file will be ready to be demuxed */
do { do {
if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) { if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
av_free(st->codec.extradata); av_free(st->codec->extradata);
return AVERROR_IO; return AVERROR_IO;
} }
chunk_tag = BE_32(&scratch[0]); chunk_tag = BE_32(&scratch[0]);

View File

@ -33,22 +33,22 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
char *colorspace = ""; char *colorspace = "";
st = s->streams[0]; st = s->streams[0];
width = st->codec.width; width = st->codec->width;
height = st->codec.height; height = st->codec->height;
av_reduce(&raten, &rated, st->codec.time_base.den, st->codec.time_base.num, (1UL<<31)-1); av_reduce(&raten, &rated, st->codec->time_base.den, st->codec->time_base.num, (1UL<<31)-1);
aspectn = st->codec.sample_aspect_ratio.num; aspectn = st->codec->sample_aspect_ratio.num;
aspectd = st->codec.sample_aspect_ratio.den; aspectd = st->codec->sample_aspect_ratio.den;
if ( aspectn == 0 && aspectd == 1 ) aspectd = 0; // 0:0 means unknown if ( aspectn == 0 && aspectd == 1 ) aspectd = 0; // 0:0 means unknown
inter = 'p'; /* progressive is the default */ inter = 'p'; /* progressive is the default */
if (st->codec.coded_frame && st->codec.coded_frame->interlaced_frame) { if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) {
inter = st->codec.coded_frame->top_field_first ? 't' : 'b'; inter = st->codec->coded_frame->top_field_first ? 't' : 'b';
} }
switch(st->codec.pix_fmt) { switch(st->codec->pix_fmt) {
case PIX_FMT_GRAY8: case PIX_FMT_GRAY8:
colorspace = " Cmono"; colorspace = " Cmono";
break; break;
@ -56,7 +56,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
colorspace = " C411 XYSCSS=411"; colorspace = " C411 XYSCSS=411";
break; break;
case PIX_FMT_YUV420P: case PIX_FMT_YUV420P:
colorspace = (st->codec.codec_id == CODEC_ID_DVVIDEO)?" C420paldv XYSCSS=420PALDV":" C420mpeg2 XYSCSS=420MPEG2"; colorspace = (st->codec->codec_id == CODEC_ID_DVVIDEO)?" C420paldv XYSCSS=420PALDV":" C420mpeg2 XYSCSS=420MPEG2";
break; break;
case PIX_FMT_YUV422P: case PIX_FMT_YUV422P:
colorspace = " C422 XYSCSS=422"; colorspace = " C422 XYSCSS=422";
@ -109,8 +109,8 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC); m = snprintf(buf1, sizeof(buf1), "%s\n", Y4M_FRAME_MAGIC);
put_buffer(pb, buf1, strlen(buf1)); put_buffer(pb, buf1, strlen(buf1));
width = st->codec.width; width = st->codec->width;
height = st->codec.height; height = st->codec->height;
ptr = picture->data[0]; ptr = picture->data[0];
for(i=0;i<height;i++) { for(i=0;i<height;i++) {
@ -118,9 +118,9 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt)
ptr += picture->linesize[0]; ptr += picture->linesize[0];
} }
if (st->codec.pix_fmt != PIX_FMT_GRAY8){ if (st->codec->pix_fmt != PIX_FMT_GRAY8){
// Adjust for smaller Cb and Cr planes // Adjust for smaller Cb and Cr planes
avcodec_get_chroma_sub_sample(st->codec.pix_fmt, &h_chroma_shift, &v_chroma_shift); avcodec_get_chroma_sub_sample(st->codec->pix_fmt, &h_chroma_shift, &v_chroma_shift);
width >>= h_chroma_shift; width >>= h_chroma_shift;
height >>= v_chroma_shift; height >>= v_chroma_shift;
@ -146,13 +146,13 @@ static int yuv4_write_header(AVFormatContext *s)
if (s->nb_streams != 1) if (s->nb_streams != 1)
return AVERROR_IO; return AVERROR_IO;
if (s->streams[0]->codec.pix_fmt == PIX_FMT_YUV411P) { if (s->streams[0]->codec->pix_fmt == PIX_FMT_YUV411P) {
av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n"); av_log(s, AV_LOG_ERROR, "Warning: generating rarely used 4:1:1 YUV stream, some mjpegtools might not work.\n");
} }
else if ((s->streams[0]->codec.pix_fmt != PIX_FMT_YUV420P) && else if ((s->streams[0]->codec->pix_fmt != PIX_FMT_YUV420P) &&
(s->streams[0]->codec.pix_fmt != PIX_FMT_YUV422P) && (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV422P) &&
(s->streams[0]->codec.pix_fmt != PIX_FMT_GRAY8) && (s->streams[0]->codec->pix_fmt != PIX_FMT_GRAY8) &&
(s->streams[0]->codec.pix_fmt != PIX_FMT_YUV444P)) { (s->streams[0]->codec->pix_fmt != PIX_FMT_YUV444P)) {
av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n"); av_log(s, AV_LOG_ERROR, "ERROR: yuv4mpeg only handles yuv444p, yuv422p, yuv420p, yuv411p and gray pixel formats. Use -pix_fmt to select one.\n");
return AVERROR_IO; return AVERROR_IO;
} }
@ -320,14 +320,14 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap)
st = av_new_stream(s, 0); st = av_new_stream(s, 0);
st = s->streams[0]; st = s->streams[0];
st->codec.width = width; st->codec->width = width;
st->codec.height = height; st->codec->height = height;
av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1); av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1);
av_set_pts_info(st, 64, rated, raten); av_set_pts_info(st, 64, rated, raten);
st->codec.pix_fmt = pix_fmt; st->codec->pix_fmt = pix_fmt;
st->codec.codec_type = CODEC_TYPE_VIDEO; st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = CODEC_ID_RAWVIDEO; st->codec->codec_id = CODEC_ID_RAWVIDEO;
st->codec.sample_aspect_ratio= (AVRational){aspectn, aspectd}; st->codec->sample_aspect_ratio= (AVRational){aspectn, aspectd};
return 0; return 0;
} }
@ -349,10 +349,10 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
if (i == MAX_FRAME_HEADER) return -1; if (i == MAX_FRAME_HEADER) return -1;
if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1; if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1;
width = st->codec.width; width = st->codec->width;
height = st->codec.height; height = st->codec->height;
packet_size = avpicture_get_size(st->codec.pix_fmt, width, height); packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
if (packet_size < 0) if (packet_size < 0)
return -1; return -1;

View File

@ -62,7 +62,7 @@ AVStream *add_audio_stream(AVFormatContext *oc, int codec_id)
exit(1); exit(1);
} }
c = &st->codec; c = st->codec;
c->codec_id = codec_id; c->codec_id = codec_id;
c->codec_type = CODEC_TYPE_AUDIO; c->codec_type = CODEC_TYPE_AUDIO;
@ -78,7 +78,7 @@ void open_audio(AVFormatContext *oc, AVStream *st)
AVCodecContext *c; AVCodecContext *c;
AVCodec *codec; AVCodec *codec;
c = &st->codec; c = st->codec;
/* find the audio encoder */ /* find the audio encoder */
codec = avcodec_find_encoder(c->codec_id); codec = avcodec_find_encoder(c->codec_id);
@ -106,7 +106,7 @@ void open_audio(AVFormatContext *oc, AVStream *st)
support to compute the input frame size in samples */ support to compute the input frame size in samples */
if (c->frame_size <= 1) { if (c->frame_size <= 1) {
audio_input_frame_size = audio_outbuf_size / c->channels; audio_input_frame_size = audio_outbuf_size / c->channels;
switch(st->codec.codec_id) { switch(st->codec->codec_id) {
case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16LE:
case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16LE:
@ -145,7 +145,7 @@ void write_audio_frame(AVFormatContext *oc, AVStream *st)
AVPacket pkt; AVPacket pkt;
av_init_packet(&pkt); av_init_packet(&pkt);
c = &st->codec; c = st->codec;
get_audio_frame(samples, audio_input_frame_size, c->channels); get_audio_frame(samples, audio_input_frame_size, c->channels);
@ -165,7 +165,7 @@ void write_audio_frame(AVFormatContext *oc, AVStream *st)
void close_audio(AVFormatContext *oc, AVStream *st) void close_audio(AVFormatContext *oc, AVStream *st)
{ {
avcodec_close(&st->codec); avcodec_close(st->codec);
av_free(samples); av_free(samples);
av_free(audio_outbuf); av_free(audio_outbuf);
@ -190,7 +190,7 @@ AVStream *add_video_stream(AVFormatContext *oc, int codec_id)
exit(1); exit(1);
} }
c = &st->codec; c = st->codec;
c->codec_id = codec_id; c->codec_id = codec_id;
c->codec_type = CODEC_TYPE_VIDEO; c->codec_type = CODEC_TYPE_VIDEO;
@ -246,7 +246,7 @@ void open_video(AVFormatContext *oc, AVStream *st)
AVCodec *codec; AVCodec *codec;
AVCodecContext *c; AVCodecContext *c;
c = &st->codec; c = st->codec;
/* find the video encoder */ /* find the video encoder */
codec = avcodec_find_encoder(c->codec_id); codec = avcodec_find_encoder(c->codec_id);
@ -317,7 +317,7 @@ void write_video_frame(AVFormatContext *oc, AVStream *st)
int out_size, ret; int out_size, ret;
AVCodecContext *c; AVCodecContext *c;
c = &st->codec; c = st->codec;
if (frame_count >= STREAM_NB_FRAMES) { if (frame_count >= STREAM_NB_FRAMES) {
/* no more frame to compress. The codec has a latency of a few /* no more frame to compress. The codec has a latency of a few
@ -379,7 +379,7 @@ void write_video_frame(AVFormatContext *oc, AVStream *st)
void close_video(AVFormatContext *oc, AVStream *st) void close_video(AVFormatContext *oc, AVStream *st)
{ {
avcodec_close(&st->codec); avcodec_close(st->codec);
av_free(picture->data[0]); av_free(picture->data[0]);
av_free(picture); av_free(picture);
if (tmp_picture) { if (tmp_picture) {