diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2005-07-17 22:24:36 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2005-07-17 22:24:36 +0000 |
commit | 01f4895c682a1752bf6d138ffb0628470e16b85a (patch) | |
tree | 56a3dfce270dad38b97c8f7ff288cc23cfac54da | |
parent | 4c1a012e9ceb0840688c547625208e7c4b81624a (diff) | |
download | ffmpeg-01f4895c682a1752bf6d138ffb0628470e16b85a.tar.gz |
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
56 files changed, 1024 insertions, 1025 deletions
@@ -493,7 +493,7 @@ static void do_audio_out(AVFormatContext *s, const int audio_out_size= 4*MAX_AUDIO_PACKET_SIZE; int size_out, frame_bytes, ret; - AVCodecContext *enc= &ost->st->codec; + AVCodecContext *enc= ost->st->codec; /* SC: dynamic allocation of buffers */ if (!audio_buf) @@ -505,9 +505,9 @@ static void do_audio_out(AVFormatContext *s, if(audio_sync_method){ double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts - - fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec.channels * 2); - double idelta= delta*ist->st->codec.sample_rate / enc->sample_rate; - int byte_delta= ((int)idelta)*2*ist->st->codec.channels; + - fifo_size(&ost->fifo, ost->fifo.rptr)/(ost->st->codec->channels * 2); + double idelta= delta*ist->st->codec->sample_rate / enc->sample_rate; + int byte_delta= ((int)idelta)*2*ist->st->codec->channels; //FIXME resample delay if(fabs(delta) > 50){ @@ -542,19 +542,19 @@ static void do_audio_out(AVFormatContext *s, assert(ost->audio_resample); if(verbose > 2) 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); } } }else 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) { buftmp = audio_buf; size_out = audio_resample(ost->resample, (short *)buftmp, (short *)buf, - size / (ist->st->codec.channels * 2)); + size / (ist->st->codec->channels * 2)); size_out = size_out * enc->channels * 2; } else { buftmp = buf; @@ -625,7 +625,7 @@ static void pre_process_video_frame(AVInputStream *ist, AVPicture *picture, void AVPicture picture_tmp; uint8_t *buf = 0; - dec = &ist->st->codec; + dec = ist->st->codec; /* deinterlace : must be done before any resize */ if (do_deinterlace || using_vhook) { @@ -721,7 +721,7 @@ static void do_subtitle_out(AVFormatContext *s, return; } - enc = &ost->st->codec; + enc = ost->st->codec; if (!subtitle_out) { 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_crop_temp); - enc = &ost->st->codec; - dec = &ist->st->codec; + enc = ost->st->codec; + dec = ist->st->codec; /* by default, we output a single frame */ nb_frames = 1; @@ -1049,7 +1049,7 @@ static void do_video_stats(AVFormatContext *os, AVOutputStream *ost, } ti = MAXINT64; - enc = &ost->st->codec; + enc = ost->st->codec; if (enc->codec_type == CODEC_TYPE_VIDEO) { frame_number = ost->frame_number; 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++) { ost = ost_table[i]; os = output_files[ost->file_index]; - enc = &ost->st->codec; + enc = ost->st->codec; if (vid && enc->codec_type == CODEC_TYPE_VIDEO) { snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", enc->coded_frame->quality/(float)FF_QP2LAMBDA); @@ -1220,13 +1220,13 @@ static int output_packet(AVInputStream *ist, int ist_index, data_size = 0; subtitle_to_free = NULL; if (ist->decoding_needed) { - switch(ist->st->codec.codec_type) { + switch(ist->st->codec->codec_type) { case CODEC_TYPE_AUDIO:{ if(pkt) 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 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); if (ret < 0) goto fail_decode; @@ -1240,14 +1240,14 @@ static int output_packet(AVInputStream *ist, int ist_index, } data_buf = (uint8_t *)samples; 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;} 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 */ avcodec_get_frame_defaults(&picture); - ret = avcodec_decode_video(&ist->st->codec, + ret = avcodec_decode_video(ist->st->codec, &picture, &got_picture, ptr, len); ist->st->quality= picture.quality; if (ret < 0) @@ -1256,15 +1256,15 @@ static int output_packet(AVInputStream *ist, int ist_index, /* no picture yet */ 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->st->codec.time_base.num) / - ist->st->codec.time_base.den; + ist->st->codec->time_base.num) / + ist->st->codec->time_base.den; } len = 0; break; case CODEC_TYPE_SUBTITLE: - ret = avcodec_decode_subtitle(&ist->st->codec, + ret = avcodec_decode_subtitle(ist->st->codec, &subtitle, &got_subtitle, ptr, len); if (ret < 0) goto fail_decode; @@ -1278,16 +1278,16 @@ static int output_packet(AVInputStream *ist, int ist_index, goto fail_decode; } } else { - switch(ist->st->codec.codec_type) { + switch(ist->st->codec->codec_type) { case CODEC_TYPE_AUDIO: - ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec.frame_size) / - (ist->st->codec.sample_rate * ist->st->codec.channels); + ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec->frame_size) / + (ist->st->codec->sample_rate * ist->st->codec->channels); break; 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->st->codec.time_base.num) / - ist->st->codec.time_base.den; + ist->st->codec->time_base.num) / + ist->st->codec->time_base.den; } break; } @@ -1298,13 +1298,13 @@ static int output_packet(AVInputStream *ist, int ist_index, } 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, &buffer_to_free); } // 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) { short *volp; volp = samples; @@ -1318,8 +1318,8 @@ static int output_packet(AVInputStream *ist, int ist_index, } /* frame rate emulation */ - 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); + 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 now = av_gettime() - ist->start; if (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 is the one of the next displayed one */ /* XXX: add mpeg4 too ? */ - if (ist->st->codec.codec_id == CODEC_ID_MPEG1VIDEO) { - if (ist->st->codec.pict_type != B_TYPE) { + if (ist->st->codec->codec_id == CODEC_ID_MPEG1VIDEO) { + if (ist->st->codec->pict_type != B_TYPE) { int64_t tmp; tmp = ist->last_ip_pts; 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; if (ost->encoding_needed) { - switch(ost->st->codec.codec_type) { + switch(ost->st->codec->codec_type) { case CODEC_TYPE_AUDIO: do_audio_out(os, ost, ist, data_buf, data_size); break; @@ -1386,12 +1386,12 @@ static int output_packet(AVInputStream *ist, int ist_index, /* force the input stream PTS */ 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; - if(ost->st->codec.codec_type == CODEC_TYPE_AUDIO) + if(ost->st->codec->codec_type == CODEC_TYPE_AUDIO) 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; 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.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; av_interleaved_write_frame(os, &opkt); - ost->st->codec.frame_number++; + ost->st->codec->frame_number++; ost->frame_number++; av_free_packet(&opkt); } @@ -1441,12 +1441,12 @@ static int output_packet(AVInputStream *ist, int ist_index, for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->source_index == ist_index) { - AVCodecContext *enc= &ost->st->codec; + AVCodecContext *enc= ost->st->codec; 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; - 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; if (ost->encoding_needed) { @@ -1455,7 +1455,7 @@ static int output_packet(AVInputStream *ist, int ist_index, av_init_packet(&pkt); pkt.stream_index= ost->index; - switch(ost->st->codec.codec_type) { + switch(ost->st->codec->codec_type) { case CODEC_TYPE_AUDIO: ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, NULL); audio_size += ret; @@ -1546,7 +1546,7 @@ static int av_encode(AVFormatContext **output_files, ist->discard = 1; /* the stream is discarded by default (changed later) */ - if (ist->st->codec.rate_emu) { + if (ist->st->codec->rate_emu) { ist->start = av_gettime(); ist->frame = 0; } @@ -1607,7 +1607,7 @@ static int av_encode(AVFormatContext **output_files, stream_maps[n-1].stream_index; /* 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", stream_maps[n-1].file_index, stream_maps[n-1].stream_index, ost->file_index, ost->index); @@ -1620,7 +1620,7 @@ static int av_encode(AVFormatContext **output_files, for(j=0;j<nb_istreams;j++) { ist = ist_table[j]; 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; found = 1; break; @@ -1631,7 +1631,7 @@ static int av_encode(AVFormatContext **output_files, /* try again and reuse existing stream */ for(j=0;j<nb_istreams;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; found = 1; } @@ -1656,8 +1656,8 @@ static int av_encode(AVFormatContext **output_files, ost = ost_table[i]; ist = ist_table[ost->source_index]; - codec = &ost->st->codec; - icodec = &ist->st->codec; + codec = ost->st->codec; + icodec = ist->st->codec; if (ost->st->stream_copy) { /* if stream_copy is selected, no need to decode or encode */ @@ -1773,8 +1773,8 @@ static int av_encode(AVFormatContext **output_files, goto fail; ost->img_resample_ctx = img_resample_full_init( - ost->st->codec.width, ost->st->codec.height, - ist->st->codec.width, ist->st->codec.height, + ost->st->codec->width, ost->st->codec->height, + ist->st->codec->width, ist->st->codec->height, frame_topBand, frame_bottomBand, frame_leftBand, frame_rightBand, frame_padtop, frame_padbottom, @@ -1877,18 +1877,18 @@ static int av_encode(AVFormatContext **output_files, ost = ost_table[i]; if (ost->encoding_needed) { AVCodec *codec; - codec = avcodec_find_encoder(ost->st->codec.codec_id); + codec = avcodec_find_encoder(ost->st->codec->codec_id); if (!codec) { fprintf(stderr, "Unsupported codec for output stream #%d.%d\n", ost->file_index, ost->index); 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", ost->file_index, ost->index); 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]; if (ist->decoding_needed) { AVCodec *codec; - codec = avcodec_find_decoder(ist->st->codec.codec_id); + codec = avcodec_find_decoder(ist->st->codec->codec_id); if (!codec) { 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); } - 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", ist->file_index, ist->index); exit(1); } - //if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO) - // ist->st->codec.flags |= CODEC_FLAG_REPEAT_FIELD; + //if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO) + // ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD; } } @@ -2010,8 +2010,8 @@ static int av_encode(AVFormatContext **output_files, ost = ost_table[i]; os = output_files[ost->file_index]; ist = ist_table[ost->source_index]; - if(ost->st->codec.codec_type == CODEC_TYPE_VIDEO) - opts = ost->sync_opts * av_q2d(ost->st->codec.time_base); + if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO) + opts = ost->sync_opts * av_q2d(ost->st->codec->time_base); else opts = ost->st->pts.val * av_q2d(ost->st->time_base); ipts = (double)ist->pts; @@ -2025,7 +2025,7 @@ static int av_encode(AVFormatContext **output_files, 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; break; } @@ -2067,7 +2067,7 @@ static int av_encode(AVFormatContext **output_files, if (ist->discard) 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) { 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){ @@ -2123,8 +2123,8 @@ static int av_encode(AVFormatContext **output_files, for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->encoding_needed) { - av_freep(&ost->st->codec.stats_in); - avcodec_close(&ost->st->codec); + av_freep(&ost->st->codec->stats_in); + avcodec_close(ost->st->codec); } } @@ -2132,7 +2132,7 @@ static int av_encode(AVFormatContext **output_files, for(i=0;i<nb_istreams;i++) { ist = ist_table[i]; 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 */ 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(thread_count>1) 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++) { ic = input_files[j]; for(i=0;i<ic->nb_streams;i++) { - AVCodecContext *enc = &ic->streams[i]->codec; + AVCodecContext *enc = ic->streams[i]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: has_audio = 1; @@ -3187,10 +3187,10 @@ static void new_video_stream(AVFormatContext *oc) } #if defined(HAVE_THREADS) if(thread_count>1) - avcodec_thread_init(&st->codec, thread_count); + avcodec_thread_init(st->codec, thread_count); #endif - video_enc = &st->codec; + video_enc = st->codec; if(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(thread_count>1) - avcodec_thread_init(&st->codec, thread_count); + avcodec_thread_init(st->codec, thread_count); #endif - audio_enc = &st->codec; + audio_enc = st->codec; audio_enc->codec_type = CODEC_TYPE_AUDIO; if(audio_codec_tag) @@ -3535,7 +3535,7 @@ static void opt_new_subtitle_stream(void) exit(1); } - subtitle_enc = &st->codec; + subtitle_enc = st->codec; subtitle_enc->codec_type = CODEC_TYPE_SUBTITLE; if (subtitle_stream_copy) { st->stream_copy = 1; @@ -3732,7 +3732,7 @@ static void prepare_grab(void) for(j=0;j<nb_output_files;j++) { oc = output_files[j]; for(i=0;i<oc->nb_streams;i++) { - AVCodecContext *enc = &oc->streams[i]->codec; + AVCodecContext *enc = oc->streams[i]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: if (enc->sample_rate > ap->sample_rate) @@ -4041,7 +4041,7 @@ static void opt_target(const char *arg) int i, j; for(j = 0; j < nb_input_files; j++) { 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) continue; fr = c->time_base.den * 1000 / c->time_base.num; @@ -381,24 +381,24 @@ static void video_image_display(VideoState *is) vp = &is->pictq[is->pictq_rindex]; if (vp->bmp) { /* 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; else - aspect_ratio = av_q2d(is->video_st->codec.sample_aspect_ratio) - * is->video_st->codec.width / is->video_st->codec.height;; + aspect_ratio = av_q2d(is->video_st->codec->sample_aspect_ratio) + * is->video_st->codec->width / is->video_st->codec->height;; if (aspect_ratio <= 0.0) - aspect_ratio = (float)is->video_st->codec.width / - (float)is->video_st->codec.height; + aspect_ratio = (float)is->video_st->codec->width / + (float)is->video_st->codec->height; /* if an active format is indicated, then it overrides the mpeg format */ #if 0 - if (is->video_st->codec.dtg_active_format != is->dtg_active_format) { - is->dtg_active_format = is->video_st->codec.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; printf("dtg_active_format=%d\n", is->dtg_active_format); } #endif #if 0 - switch(is->video_st->codec.dtg_active_format) { + switch(is->video_st->codec->dtg_active_format) { case FF_DTG_AFD_SAME: default: /* nothing to do */ @@ -469,7 +469,7 @@ static void video_audio_display(VideoState *s) int16_t time_diff; /* compute display index : center on currently output samples */ - channels = s->audio_st->codec.channels; + channels = s->audio_st->codec->channels; nb_display_channels = channels; if (!s->paused) { n = 2 * channels; @@ -480,7 +480,7 @@ static void video_audio_display(VideoState *s) the last buffer computation */ if (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; @@ -567,8 +567,8 @@ static double get_audio_clock(VideoState *is) hw_buf_size = audio_write_get_buf_size(is); bytes_per_sec = 0; if (is->audio_st) { - bytes_per_sec = is->audio_st->codec.sample_rate * - 2 * is->audio_st->codec.channels; + bytes_per_sec = is->audio_st->codec->sample_rate * + 2 * is->audio_st->codec->channels; } if (bytes_per_sec) pts -= (double)hw_buf_size / bytes_per_sec; @@ -767,7 +767,7 @@ static void alloc_picture(void *opaque) #if 0 /* XXX: use generic function */ /* 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_YUV422P: case PIX_FMT_YUV444P: @@ -781,12 +781,12 @@ static void alloc_picture(void *opaque) break; } #endif - vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec.width, - is->video_st->codec.height, + vp->bmp = SDL_CreateYUVOverlay(is->video_st->codec->width, + is->video_st->codec->height, SDL_YV12_OVERLAY, screen); - vp->width = is->video_st->codec.width; - vp->height = is->video_st->codec.height; + vp->width = is->video_st->codec->width; + vp->height = is->video_st->codec->height; SDL_LockMutex(is->pictq_mutex); vp->allocated = 1; @@ -815,8 +815,8 @@ static int queue_picture(VideoState *is, AVFrame *src_frame, double pts) /* alloc or resize hardware picture buffer */ if (!vp->bmp || - vp->width != is->video_st->codec.width || - vp->height != is->video_st->codec.height) { + vp->width != is->video_st->codec->width || + vp->height != is->video_st->codec->height) { SDL_Event event; 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[2] = vp->bmp->pitches[1]; img_convert(&pict, dst_pix_fmt, - (AVPicture *)src_frame, is->video_st->codec.pix_fmt, - is->video_st->codec.width, is->video_st->codec.height); + (AVPicture *)src_frame, is->video_st->codec->pix_fmt, + is->video_st->codec->width, is->video_st->codec->height); /* update the bitmap content */ SDL_UnlockYUVOverlay(vp->bmp); @@ -883,7 +883,7 @@ static int output_picture2(VideoState *is, AVFrame *src_frame, double pts1) pts = is->video_clock; } /* 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 clock accordingly */ 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; 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, pkt->data, pkt->size); 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; - channels = is->audio_st->codec.channels; + channels = is->audio_st->codec->channels; size = samples_size / sizeof(short); while (size > 0) { @@ -977,7 +977,7 @@ static int synchronize_audio(VideoState *is, short *samples, int n, samples_size; double ref_clock; - n = 2 * is->audio_st->codec.channels; + n = 2 * is->audio_st->codec->channels; samples_size = samples_size1; /* 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); 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; 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 */ while (is->audio_pkt_size > 0) { 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, is->audio_pkt_data, is->audio_pkt_size); 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 */ pts = is->audio_clock; *pts_ptr = pts; - n = 2 * is->audio_st->codec.channels; + n = 2 * is->audio_st->codec->channels; 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) { 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) return -1; - enc = &ic->streams[stream_index]->codec; + enc = ic->streams[stream_index]->codec; /* prepare audio output */ 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; AVCodecContext *enc; - enc = &ic->streams[stream_index]->codec; + enc = ic->streams[stream_index]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: @@ -1387,7 +1387,7 @@ static int decode_thread(void *arg) } for(i = 0; i < ic->nb_streams; i++) { - AVCodecContext *enc = &ic->streams[i]->codec; + AVCodecContext *enc = ic->streams[i]->codec; switch(enc->codec_type) { case CODEC_TYPE_AUDIO: if (audio_index < 0 && !audio_disable) @@ -1455,7 +1455,7 @@ static int decode_thread(void *arg) } if (is->video_stream >= 0) { 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); @@ -1594,12 +1594,12 @@ void stream_cycle_channel(VideoState *is, int codec_type) if (stream_index == start_index) return; st = ic->streams[stream_index]; - if (st->codec.codec_type == codec_type) { + if (st->codec->codec_type == codec_type) { /* check that parameters are OK */ switch(codec_type) { case CODEC_TYPE_AUDIO: - if (st->codec.sample_rate != 0 && - st->codec.channels != 0) + if (st->codec->sample_rate != 0 && + st->codec->channels != 0) goto the_end; break; case CODEC_TYPE_VIDEO: diff --git a/ffserver.c b/ffserver.c index f1777a9618..6c0707be71 100644 --- a/ffserver.c +++ b/ffserver.c @@ -728,8 +728,8 @@ static void close_connection(HTTPContext *c) /* close each frame parser */ for(i=0;i<c->fmt_in->nb_streams;i++) { st = c->fmt_in->streams[i]; - if (st->codec.codec) { - avcodec_close(&st->codec); + if (st->codec->codec) { + avcodec_close(st->codec); } } 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; 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 || feed_codec->sample_rate != codec->sample_rate || @@ -1044,7 +1044,7 @@ static int modify_current_stream(HTTPContext *c, char *rates) return 0; for (i = 0; i < req->nb_streams; i++) { - AVCodecContext *codec = &req->streams[i]->codec; + AVCodecContext *codec = req->streams[i]->codec; switch(rates[i]) { case 0: @@ -1659,10 +1659,10 @@ static void compute_stats(HTTPContext *c) for(i=0;i<stream->nb_streams;i++) { AVStream *st = stream->streams[i]; - AVCodec *codec = avcodec_find_encoder(st->codec.codec_id); - switch(st->codec.codec_type) { + AVCodec *codec = avcodec_find_encoder(st->codec->codec_id); + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: - audio_bit_rate += st->codec.bit_rate; + audio_bit_rate += st->codec->bit_rate; if (codec) { if (*audio_codec_name) audio_codec_name_extra = "..."; @@ -1670,7 +1670,7 @@ static void compute_stats(HTTPContext *c) } break; case CODEC_TYPE_VIDEO: - video_bit_rate += st->codec.bit_rate; + video_bit_rate += st->codec->bit_rate; if (codec) { if (*video_codec_name) video_codec_name_extra = "..."; @@ -1678,7 +1678,7 @@ static void compute_stats(HTTPContext *c) } break; case CODEC_TYPE_DATA: - video_bit_rate += st->codec.bit_rate; + video_bit_rate += st->codec->bit_rate; break; default: av_abort(); @@ -1744,26 +1744,26 @@ static void compute_stats(HTTPContext *c) for (i = 0; i < stream->nb_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"; char parameters[64]; parameters[0] = 0; - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: type = "audio"; break; case CODEC_TYPE_VIDEO: type = "video"; - 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); + 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); break; default: av_abort(); } 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"); @@ -1786,7 +1786,7 @@ static void compute_stats(HTTPContext *c) for(i=0;i<stream->nb_streams;i++) { AVStream *st = stream->streams[i]; FeedData *fdata = st->priv_data; - enc = &st->codec; + enc = st->codec; avcodec_string(buf, sizeof(buf), enc); avg = fdata->avg_frame_size * (float)enc->rate * 8.0; @@ -1822,10 +1822,10 @@ static void compute_stats(HTTPContext *c) if (c1->stream) { for (j = 0; j < c1->stream->nb_streams; j++) { if (!c1->stream->feed) { - bitrate += c1->stream->streams[j]->codec.bit_rate; + bitrate += c1->stream->streams[j]->codec->bit_rate; } else { 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]; AVCodec *codec; - if (!st->codec.codec) { - codec = avcodec_find_decoder(st->codec.codec_id); + if (!st->codec->codec) { + codec = avcodec_find_decoder(st->codec->codec_id); if (codec && (codec->capabilities & CODEC_CAP_PARSE_ONLY)) { - st->codec.parse_only = 1; - if (avcodec_open(&st->codec, codec) < 0) { - st->codec.parse_only = 0; + st->codec->parse_only = 1; + if (avcodec_open(st->codec, codec) < 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; for(i=0;i<c->stream->nb_streams;i++) { 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; } } @@ -2010,12 +2010,12 @@ static int http_prepare_data(HTTPContext *c) *st = *src; 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 */ /* I'm pretty sure that this is not correct... * However, without it, we crash */ - st->codec.coded_frame = &dummy_frame; + st->codec->coded_frame = &dummy_frame; } c->got_key_frame = 0; @@ -2144,13 +2144,13 @@ static int http_prepare_data(HTTPContext *c) av_free_packet(&pkt); break; } - codec = &ctx->streams[0]->codec; + codec = ctx->streams[0]->codec; /* only one stream per RTP connection */ pkt.stream_index = 0; } else { ctx = &c->fmt_ctx; /* 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); @@ -2462,8 +2462,8 @@ static int http_receive_data(HTTPContext *c) goto fail; } for (i = 0; i < s.nb_streams; i++) { - memcpy(&feed->streams[i]->codec, - &s.streams[i]->codec, sizeof(AVCodecContext)); + memcpy(feed->streams[i]->codec, + s.streams[i]->codec, sizeof(AVCodecContext)); } 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; for(i = 0; i < stream->nb_streams; i++) { st = stream->streams[i]; - if (st->codec.codec_id == CODEC_ID_MPEG2TS) { + if (st->codec->codec_id == CODEC_ID_MPEG2TS) { mediatype = "video"; } else { - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: mediatype = "audio"; 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 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) payload_type = private_payload_type++; if (stream->is_multicast) { @@ -2667,17 +2667,17 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer, mediatype, port, payload_type); if (payload_type >= RTP_PT_PRIVATE) { /* for private payload type, we need to give more info */ - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MPEG4: { uint8_t *data; url_fprintf(pb, "a=rtpmap:%d MP4V-ES/%d\n", payload_type, 90000); /* we must also add the mpeg4 header */ - data = st->codec.extradata; + data = st->codec->extradata; if (data) { 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, "\n"); @@ -3222,8 +3222,8 @@ static AVStream *add_av_stream1(FFStream *stream, AVCodecContext *codec) if (!fst) return NULL; fst->priv_data = av_mallocz(sizeof(FeedData)); - memcpy(&fst->codec, codec, sizeof(AVCodecContext)); - fst->codec.coded_frame = &dummy_frame; + memcpy(fst->codec, codec, sizeof(AVCodecContext)); + fst->codec->coded_frame = &dummy_frame; fst->index = stream->nb_streams; av_set_pts_info(fst, 33, 1, 90000); stream->streams[stream->nb_streams++] = fst; @@ -3237,10 +3237,10 @@ static int add_av_stream(FFStream *feed, AVStream *st) AVCodecContext *av, *av1; int i; - av = &st->codec; + av = st->codec; for(i=0;i<feed->nb_streams;i++) { st = feed->streams[i]; - av1 = &st->codec; + av1 = st->codec; if (av1->codec_id == av->codec_id && av1->codec_type == av->codec_type && av1->bit_rate == av->bit_rate) { @@ -3297,8 +3297,8 @@ static void extract_mpeg4_header(AVFormatContext *infile) mpeg4_count = 0; for(i=0;i<infile->nb_streams;i++) { st = infile->streams[i]; - if (st->codec.codec_id == CODEC_ID_MPEG4 && - st->codec.extradata_size == 0) { + if (st->codec->codec_id == CODEC_ID_MPEG4 && + st->codec->extradata_size == 0) { mpeg4_count++; } } @@ -3310,9 +3310,9 @@ static void extract_mpeg4_header(AVFormatContext *infile) if (av_read_packet(infile, &pkt) < 0) break; st = infile->streams[pkt.stream_index]; - if (st->codec.codec_id == CODEC_ID_MPEG4 && - st->codec.extradata_size == 0) { - av_freep(&st->codec.extradata); + if (st->codec->codec_id == CODEC_ID_MPEG4 && + st->codec->extradata_size == 0) { + av_freep(&st->codec->extradata); /* fill extradata with the header */ /* XXX: we make hard suppositions here ! */ p = pkt.data; @@ -3322,9 +3322,9 @@ static void extract_mpeg4_header(AVFormatContext *infile) p[2] == 0x01 && p[3] == 0xb6) { size = p - pkt.data; // av_hex_dump(pkt.data, size); - st->codec.extradata = av_malloc(size); - st->codec.extradata_size = size; - memcpy(st->codec.extradata, pkt.data, size); + st->codec->extradata = av_malloc(size); + st->codec->extradata_size = size; + memcpy(st->codec->extradata, pkt.data, size); break; } p++; @@ -3376,7 +3376,7 @@ static void build_file_streams(void) extract_mpeg4_header(infile); 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); } @@ -3441,8 +3441,8 @@ static void build_feed_streams(void) } else { AVCodecContext *ccf, *ccs; - ccf = &sf->codec; - ccs = &ss->codec; + ccf = sf->codec; + ccs = ss->codec; #define CHECK_CODEC(x) (ccf->x != ccs->x) if (CHECK_CODEC(codec) || CHECK_CODEC(codec_type)) { @@ -3550,10 +3550,10 @@ static void compute_bandwidth(void) bandwidth = 0; for(i=0;i<stream->nb_streams;i++) { AVStream *st = stream->streams[i]; - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: case CODEC_TYPE_VIDEO: - bandwidth += st->codec.bit_rate; + bandwidth += st->codec->bit_rate; break; default: break; @@ -3665,7 +3665,7 @@ static void add_codec(FFStream *stream, AVCodecContext *av) if (!st) return; 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) diff --git a/libavformat/4xm.c b/libavformat/4xm.c index 7c0f78e6b9..d4a8036469 100644 --- a/libavformat/4xm.c +++ b/libavformat/4xm.c @@ -166,11 +166,11 @@ static int fourxm_read_header(AVFormatContext *s, fourxm->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_4XM; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = fourxm->width; - st->codec.height = fourxm->height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_4XM; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = fourxm->width; + st->codec->height = fourxm->height; } else if (fourcc_tag == strk_TAG) { /* 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; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = 1; - st->codec.channels = fourxm->tracks[current_track].channels; - st->codec.sample_rate = fourxm->tracks[current_track].sample_rate; - st->codec.bits_per_sample = fourxm->tracks[current_track].bits; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = 1; + st->codec->channels = fourxm->tracks[current_track].channels; + st->codec->sample_rate = fourxm->tracks[current_track].sample_rate; + st->codec->bits_per_sample = fourxm->tracks[current_track].bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; if (fourxm->tracks[current_track].adpcm) - st->codec.codec_id = CODEC_ID_ADPCM_4XM; - else if (st->codec.bits_per_sample == 8) - st->codec.codec_id = CODEC_ID_PCM_U8; + st->codec->codec_id = CODEC_ID_ADPCM_4XM; + else if (st->codec->bits_per_sample == 8) + st->codec->codec_id = CODEC_ID_PCM_U8; else - st->codec.codec_id = CODEC_ID_PCM_S16LE; + st->codec->codec_id = CODEC_ID_PCM_S16LE; } } diff --git a/libavformat/amr.c b/libavformat/amr.c index 64c387b5ee..cbe8695330 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -31,7 +31,7 @@ static const unsigned char AMRWB_header [] = "#!AMR-WB\n"; static int amr_write_header(AVFormatContext *s) { ByteIOContext *pb = &s->pb; - AVCodecContext *enc = &s->streams[0]->codec; + AVCodecContext *enc = s->streams[0]->codec; s->priv_data = NULL; @@ -100,11 +100,11 @@ static int amr_read_header(AVFormatContext *s, return AVERROR_NOMEM; } - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = MKTAG('s', 'a', 'w', 'b'); - st->codec.codec_id = CODEC_ID_AMR_WB; - st->codec.channels = 1; - st->codec.sample_rate = 16000; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = MKTAG('s', 'a', 'w', 'b'); + st->codec->codec_id = CODEC_ID_AMR_WB; + st->codec->channels = 1; + st->codec->sample_rate = 16000; } else { @@ -114,11 +114,11 @@ static int amr_read_header(AVFormatContext *s, return AVERROR_NOMEM; } - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = MKTAG('s', 'a', 'm', 'r'); - st->codec.codec_id = CODEC_ID_AMR_NB; - st->codec.channels = 1; - st->codec.sample_rate = 8000; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = MKTAG('s', 'a', 'm', 'r'); + st->codec->codec_id = CODEC_ID_AMR_NB; + st->codec->channels = 1; + st->codec->sample_rate = 8000; } return 0; @@ -129,7 +129,7 @@ static int amr_read_header(AVFormatContext *s, static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) { - AVCodecContext *enc = &s->streams[0]->codec; + AVCodecContext *enc = s->streams[0]->codec; if (enc->codec_id == CODEC_ID_AMR_NB) { diff --git a/libavformat/asf-enc.c b/libavformat/asf-enc.c index 4e2fd35072..a6b3f032e1 100644 --- a/libavformat/asf-enc.c +++ b/libavformat/asf-enc.c @@ -289,7 +289,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data bit_rate = 0; 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 */ @@ -353,7 +353,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data int er_spr_len = 0; // ASFStream *stream = &asf->streams[n]; - enc = &s->streams[n]->codec; + enc = s->streams[n]->codec; asf->streams[n].num = n + 1; 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++) { AVCodec *p; - enc = &s->streams[n]->codec; + enc = s->streams[n]->codec; p = avcodec_find_encoder(enc->codec_id); 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; int start_sec,i; - codec = &s->streams[pkt->stream_index]->codec; + codec = s->streams[pkt->stream_index]->codec; stream = &asf->streams[pkt->stream_index]; //XXX /FIXME use duration from AVPacket (quick hack by) diff --git a/libavformat/asf.c b/libavformat/asf.c index c52b1da7dc..12d2a5ed32 100644 --- a/libavformat/asf.c +++ b/libavformat/asf.c @@ -216,9 +216,9 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) asf->asfid2avid[st->id] = s->nb_streams - 1; get_le32(pb); - st->codec.codec_type = type; + st->codec->codec_type = type; 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; /* We have to init the frame size at some point .... */ 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_span = 0; // disable descrambling } - switch (st->codec.codec_id) { + switch (st->codec->codec_id) { case CODEC_ID_MP3: - st->codec.frame_size = MPA_FRAME_SIZE; + st->codec->frame_size = MPA_FRAME_SIZE; break; case CODEC_ID_PCM_S16LE: 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_ALAW: case CODEC_ID_PCM_MULAW: - st->codec.frame_size = 1; + st->codec->frame_size = 1; break; default: /* This is probably wrong, but it prevents a crash later */ - st->codec.frame_size = 1; + st->codec->frame_size = 1; break; } } else { @@ -262,38 +262,38 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) get_byte(pb); size = get_le16(pb); /* size */ sizeX= get_le32(pb); /* size */ - st->codec.width = get_le32(pb); - st->codec.height = get_le32(pb); + st->codec->width = get_le32(pb); + st->codec->height = get_le32(pb); /* not available for asf */ 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); url_fskip(pb, 20); // av_log(NULL, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX); size= sizeX; if (size > 40) { - st->codec.extradata_size = size - 40; - st->codec.extradata = av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size = size - 40; + st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } /* Extract palette from extradata if bpp <= 8 */ /* This code assumes that extradata contains only palette */ /* This is true for all paletted codecs implemented in ffmpeg */ - if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { - st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); + if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) { + st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #ifdef WORDS_BIGENDIAN - 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]); + 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]); #else - memcpy(st->codec.palctrl->palette, st->codec.extradata, - FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); + memcpy(st->codec->palctrl->palette, st->codec->extradata, + FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif - st->codec.palctrl->palette_changed = 1; + st->codec->palctrl->palette_changed = 1; } - st->codec.codec_tag = tag1; - st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); + st->codec->codec_tag = tag1; + st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1); if(tag1 == MKTAG('D', 'V', 'R', ' ')) st->need_parsing = 1; } @@ -398,7 +398,7 @@ static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) AVStream *st = s->streams[i]; if (st) { av_free(st->priv_data); - av_free(st->codec.extradata); + av_free(st->codec->extradata); } av_free(st); } @@ -608,8 +608,8 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt) asf_st->packet_pos= asf->packet_pos; //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, -//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) +//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) asf->packet_key_frame = 1; if (asf->packet_key_frame) 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++) { AVStream *st = s->streams[i]; av_free(st->priv_data); - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + av_free(st->codec->extradata); + av_free(st->codec->palctrl); } return 0; } diff --git a/libavformat/au.c b/libavformat/au.c index 984180ab4b..1777747a92 100644 --- a/libavformat/au.c +++ b/libavformat/au.c @@ -63,7 +63,7 @@ static int au_write_header(AVFormatContext *s) s->priv_data = NULL; /* format header */ - if (put_au_header(pb, &s->streams[0]->codec) < 0) { + if (put_au_header(pb, s->streams[0]->codec) < 0) { return -1; } @@ -143,11 +143,11 @@ static int au_read_header(AVFormatContext *s, st = av_new_stream(s, 0); if (!st) return -1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = id; - st->codec.codec_id = codec; - st->codec.channels = channels; - st->codec.sample_rate = rate; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = id; + st->codec->codec_id = codec; + st->codec->channels = channels; + st->codec->sample_rate = rate; av_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/libavformat/audio.c b/libavformat/audio.c index ec7e4365ae..054ced2266 100644 --- a/libavformat/audio.c +++ b/libavformat/audio.c @@ -162,8 +162,8 @@ static int audio_write_header(AVFormatContext *s1) int ret; st = s1->streams[0]; - s->sample_rate = st->codec.sample_rate; - s->channels = st->codec.channels; + s->sample_rate = st->codec->sample_rate; + s->channels = st->codec->channels; ret = audio_open(s, 1, NULL); if (ret < 0) { return AVERROR_IO; @@ -234,10 +234,10 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap) } /* take real parameters */ - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = s->codec_id; - st->codec.sample_rate = s->sample_rate; - st->codec.channels = s->channels; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = s->codec_id; + st->codec->sample_rate = s->sample_rate; + st->codec->channels = s->channels; av_set_pts_info(st, 48, 1, 1000000); /* 48 bits pts in us */ return 0; diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 31e6d346a4..622541453b 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -5,7 +5,7 @@ extern "C" { #endif -#define LIBAVFORMAT_BUILD 4628 +#define LIBAVFORMAT_BUILD 4629 #define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT #define LIBAVFORMAT_VERSION FFMPEG_VERSION @@ -216,7 +216,7 @@ typedef struct AVIndexEntry { typedef struct AVStream { int index; /* stream index in AVFormatContext */ int id; /* format specific stream id */ - AVCodecContext codec; /* codec context */ + AVCodecContext *codec; /* codec context */ /** * real base frame rate of the stream. * for example if the timebase is 1/90000 and all frames have either diff --git a/libavformat/avidec.c b/libavformat/avidec.c index 14fa2b5eff..f1a25899a6 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -178,7 +178,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; 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]); s->nb_streams = 0; 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]; ast = st->priv_data; - st->codec.stream_codec_tag= handler; + st->codec->stream_codec_tag= handler; get_le32(pb); /* flags */ get_le16(pb); /* priority */ @@ -259,10 +259,10 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) switch(codec_type) { case CODEC_TYPE_VIDEO: get_le32(pb); /* size */ - st->codec.width = get_le32(pb); - st->codec.height = get_le32(pb); + st->codec->width = get_le32(pb); + st->codec->height = get_le32(pb); 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); get_le32(pb); /* ImageSize */ get_le32(pb); /* XPelsPerMeter */ @@ -271,41 +271,41 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) get_le32(pb); /* ClrImportant */ if(size > 10*4 && size<(1<<30)){ - st->codec.extradata_size= size - 10*4; - st->codec.extradata= av_malloc(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size= size - 10*4; + st->codec->extradata= av_malloc(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_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); /* Extract palette from extradata if bpp <= 8 */ /* This code assumes that extradata contains only palette */ /* This is true for all paletted codecs implemented in ffmpeg */ - if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { - st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); + if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) { + st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #ifdef WORDS_BIGENDIAN - 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]); + 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]); #else - memcpy(st->codec.palctrl->palette, st->codec.extradata, - FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); + memcpy(st->codec->palctrl->palette, st->codec->extradata, + FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif - st->codec.palctrl->palette_changed = 1; + st->codec->palctrl->palette_changed = 1; } #ifdef DEBUG print_tag("video", tag1, 0); #endif - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_tag = tag1; - st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); - if (st->codec.codec_id == CODEC_ID_XAN_WC4) + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_tag = tag1; + st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1); + if (st->codec->codec_id == CODEC_ID_XAN_WC4) xan_video = 1; // url_fskip(pb, size - 5 * 4); break; 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) */ url_fskip(pb, 1); /* 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 one packet */ if (xan_video) - st->codec.codec_id = CODEC_ID_XAN_DPCM; + st->codec->codec_id = CODEC_ID_XAN_DPCM; break; default: - st->codec.codec_type = CODEC_TYPE_DATA; - st->codec.codec_id= CODEC_ID_NONE; - st->codec.codec_tag= 0; + st->codec->codec_type = CODEC_TYPE_DATA; + st->codec->codec_id= CODEC_ID_NONE; + st->codec->codec_tag= 0; url_fskip(pb, size); break; } @@ -337,7 +337,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) if (stream_index != s->nb_streams - 1) { fail: 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]); } 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); 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){ AVIndexEntry *e; int index; @@ -580,9 +580,9 @@ resync: g = get_byte(pb); b = 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; } @@ -786,8 +786,8 @@ static int avi_read_close(AVFormatContext *s) AVStream *st = s->streams[i]; AVIStream *ast = st->priv_data; av_free(ast); - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + av_free(st->codec->extradata); + av_free(st->codec->palctrl); } if (avi->dv_demux) diff --git a/libavformat/avienc.c b/libavformat/avienc.c index a035f85de6..698bce559f 100644 --- a/libavformat/avienc.c +++ b/libavformat/avienc.c @@ -338,7 +338,7 @@ static int avi_write_header(AVFormatContext *s) video_enc = NULL; for(n=0;n<s->nb_streams;n++) { - stream = &s->streams[n]->codec; + stream = s->streams[n]->codec; bitrate += stream->bit_rate; if (stream->codec_type == CODEC_TYPE_VIDEO) video_enc = stream; @@ -376,7 +376,7 @@ static int avi_write_header(AVFormatContext *s) list2 = start_tag(pb, "LIST"); put_tag(pb, "strl"); - stream = &s->streams[i]->codec; + stream = s->streams[i]->codec; /* FourCC should really be set by the codec itself */ if (! stream->codec_tag) { @@ -504,7 +504,7 @@ static int avi_write_ix(AVFormatContext *s) for (i=0;i<s->nb_streams;i++) { 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; /* Writing AVI OpenDML leaf index chunk */ @@ -576,7 +576,7 @@ static int avi_write_idx1(AVFormatContext *s) } if (!empty) { 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_le32(pb, ie->flags); put_le32(pb, ie->pos); @@ -591,7 +591,7 @@ static int avi_write_idx1(AVFormatContext *s) nb_frames = 0; for(n=0;n<s->nb_streams;n++) { 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); ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale); if (au_ssize == 0) { @@ -618,7 +618,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) unsigned char tag[5]; unsigned int flags=0; 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; // 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); 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 (nb_frames < stream->frame_number) nb_frames = stream->frame_number; diff --git a/libavformat/dv.c b/libavformat/dv.c index ff5f4bedb0..744c71746d 100644 --- a/libavformat/dv.c +++ b/libavformat/dv.c @@ -560,8 +560,8 @@ static int dv_extract_audio_info(DVDemuxContext* c, uint8_t* frame) if (!c->ast[i]) break; av_set_pts_info(c->ast[i], 64, 1, 30000); - c->ast[i]->codec.codec_type = CODEC_TYPE_AUDIO; - c->ast[i]->codec.codec_id = CODEC_ID_PCM_S16LE; + c->ast[i]->codec->codec_type = CODEC_TYPE_AUDIO; + c->ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; av_init_packet(&c->audio_pkt[i]); 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].flags |= PKT_FLAG_KEY; } - c->ast[i]->codec.sample_rate = dv_audio_frequency[freq]; - c->ast[i]->codec.channels = 2; - c->ast[i]->codec.bit_rate = 2 * dv_audio_frequency[freq] * 16; + c->ast[i]->codec->sample_rate = dv_audio_frequency[freq]; + c->ast[i]->codec->channels = 2; + c->ast[i]->codec->bit_rate = 2 * dv_audio_frequency[freq] * 16; c->ast[i]->start_time = 0; } c->ach = i; @@ -589,7 +589,7 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame) sys = dv_frame_profile(frame); if (sys) { - avctx = &c->vst->codec; + avctx = c->vst->codec; 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}; @@ -628,10 +628,10 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st, 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 */ 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); 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); 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 >= reqasize) { 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 */ 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); } @@ -682,7 +682,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) /* We have to sort out where audio and where video stream is */ 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: vst = s->streams[i]; break; @@ -695,13 +695,13 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) } /* 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; - if (ast && (ast->codec.codec_id != CODEC_ID_PCM_S16LE || - ast->codec.sample_rate != 48000 || - ast->codec.channels != 2)) + if (ast && (ast->codec->codec_id != CODEC_ID_PCM_S16LE || + ast->codec->sample_rate != 48000 || + ast->codec->channels != 2)) goto bail_out; - c->sys = dv_codec_profile(&vst->codec); + c->sys = dv_codec_profile(vst->codec); if (!c->sys) goto bail_out; @@ -711,7 +711,7 @@ DVMuxContext* dv_init_mux(AVFormatContext* s) c->has_video = 0; c->start_time = (time_t)s->timestamp; 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; 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->abytes = 0; - c->vst->codec.codec_type = CODEC_TYPE_VIDEO; - c->vst->codec.codec_id = CODEC_ID_DVVIDEO; - c->vst->codec.bit_rate = 25000000; + c->vst->codec->codec_type = CODEC_TYPE_VIDEO; + c->vst->codec->codec_id = CODEC_ID_DVVIDEO; + c->vst->codec->bit_rate = 25000000; c->vst->start_time = 0; return c; @@ -790,7 +790,7 @@ int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, size = dv_extract_audio_info(c, buf); for (i=0; i<c->ach; i++) { 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]); c->abytes += size; @@ -813,7 +813,7 @@ static int64_t dv_frame_offset(AVFormatContext *s, DVDemuxContext *c, int64_t timestamp, int flags) { // 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 size = url_fsize(&s->pb); 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; DVDemuxContext *c = r->dv_demux; 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; if (c->ach) 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); dv_flush_audio_packets(c); diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c index 2d8bdadb57..7101652dc0 100644 --- a/libavformat/electronicarts.c +++ b/libavformat/electronicarts.c @@ -188,9 +188,9 @@ static int ea_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); ea->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_EA_MJPEG; - st->codec.codec_tag = 0; /* no fourcc */ + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_EA_MJPEG; + st->codec->codec_tag = 0; /* no fourcc */ #endif /* initialize the audio decoder stream */ @@ -198,15 +198,15 @@ static int ea_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, EA_SAMPLE_RATE); - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_EA; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = ea->num_channels; - st->codec.sample_rate = EA_SAMPLE_RATE; - st->codec.bits_per_sample = EA_BITS_PER_SAMPLE; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample / 4; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_EA; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = ea->num_channels; + st->codec->sample_rate = EA_SAMPLE_RATE; + st->codec->bits_per_sample = EA_BITS_PER_SAMPLE; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; ea->audio_stream_index = st->index; ea->audio_frame_counter = 0; diff --git a/libavformat/ffm.c b/libavformat/ffm.c index 6fb069ace2..55a4f63417 100644 --- a/libavformat/ffm.c +++ b/libavformat/ffm.c @@ -141,7 +141,7 @@ static int ffm_write_header(AVFormatContext *s) bit_rate = 0; for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; - bit_rate += st->codec.bit_rate; + bit_rate += st->codec->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); st->priv_data = fst; - codec = &st->codec; + codec = st->codec; /* generic info */ put_be32(pb, codec->codec_id); put_byte(pb, codec->codec_type); @@ -247,10 +247,10 @@ static int ffm_write_packet(AVFormatContext *s, AVPacket *pkt) int size= pkt->size; //XXX/FIXME use duration from pkt - if (st->codec.codec_type == CODEC_TYPE_AUDIO) { - duration = ((float)st->codec.frame_size / st->codec.sample_rate * 1000000.0); + if (st->codec->codec_type == CODEC_TYPE_AUDIO) { + duration = ((float)st->codec->frame_size / st->codec->sample_rate * 1000000.0); } 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; @@ -485,10 +485,10 @@ static int ffm_read_header(AVFormatContext *s, AVFormatParameters *ap) st->priv_data = fst; - codec = &st->codec; + codec = st->codec; /* generic info */ - st->codec.codec_id = get_be32(pb); - st->codec.codec_type = get_byte(pb); /* codec_type */ + st->codec->codec_id = get_be32(pb); + st->codec->codec_type = get_byte(pb); /* codec_type */ codec->bit_rate = get_be32(pb); st->quality = get_be32(pb); codec->flags = get_be32(pb); diff --git a/libavformat/flic.c b/libavformat/flic.c index 3fa27335db..d53168dc98 100644 --- a/libavformat/flic.c +++ b/libavformat/flic.c @@ -86,19 +86,19 @@ static int flic_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; flic->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_FLIC; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = LE_16(&header[0x08]); - st->codec.height = LE_16(&header[0x0A]); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_FLIC; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = LE_16(&header[0x08]); + st->codec->height = LE_16(&header[0x0A]); - if (!st->codec.width || !st->codec.height) + if (!st->codec->width || !st->codec->height) return AVERROR_INVALIDDATA; /* send over the whole 128-byte FLIC header */ - st->codec.extradata_size = FLIC_HEADER_SIZE; - st->codec.extradata = av_malloc(FLIC_HEADER_SIZE); - memcpy(st->codec.extradata, header, FLIC_HEADER_SIZE); + st->codec->extradata_size = FLIC_HEADER_SIZE; + st->codec->extradata = av_malloc(FLIC_HEADER_SIZE); + memcpy(st->codec->extradata, header, FLIC_HEADER_SIZE); 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); /* send over abbreviated FLIC header chunk */ - av_free(st->codec.extradata); - st->codec.extradata_size = 12; - st->codec.extradata = av_malloc(12); - memcpy(st->codec.extradata, header, 12); + av_free(st->codec->extradata); + st->codec->extradata_size = 12; + st->codec->extradata = av_malloc(12); + memcpy(st->codec->extradata, header, 12); } else if (magic_number == FLIC_FILE_MAGIC_1) { /* diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 187a692ea9..b309c5b55f 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -102,7 +102,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_NOMEM; 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); 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(st->codec.sample_rate == 0){ - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.channels = (flags&1)+1; + if(st->codec->sample_rate == 0){ + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->channels = (flags&1)+1; if((flags >> 4) == 5) - st->codec.sample_rate= 8000; + st->codec->sample_rate= 8000; 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*/ - case 0: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16BE; - else st->codec.codec_id = CODEC_ID_PCM_S8; break; - case 1: st->codec.codec_id = CODEC_ID_ADPCM_SWF; break; - case 2: st->codec.codec_id = CODEC_ID_MP3; break; + case 0: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16BE; + else st->codec->codec_id = CODEC_ID_PCM_S8; break; + case 1: st->codec->codec_id = CODEC_ID_ADPCM_SWF; break; + case 2: st->codec->codec_id = CODEC_ID_MP3; break; // this is not listed at FLV but at SWF, strange... - case 3: if (flags&2) st->codec.codec_id = CODEC_ID_PCM_S16LE; - else st->codec.codec_id = CODEC_ID_PCM_S8; break; + case 3: if (flags&2) st->codec->codec_id = CODEC_ID_PCM_S16LE; + else st->codec->codec_id = CODEC_ID_PCM_S8; break; default: 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{ - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; switch(flags & 0xF){ - case 2: st->codec.codec_id = CODEC_ID_FLV1; break; + case 2: st->codec->codec_id = CODEC_ID_FLV1; break; default: 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; } } diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c index 29b94598da..5f3f4c5af7 100644 --- a/libavformat/flvenc.c +++ b/libavformat/flvenc.c @@ -97,7 +97,7 @@ static int flv_write_header(AVFormatContext *s) put_be32(pb,0); 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 */ if(enc->codec_tag == 5){ 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) { 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; int size= pkt->size; int flags; diff --git a/libavformat/gif.c b/libavformat/gif.c index 1248139d79..be5b7b973d 100644 --- a/libavformat/gif.c +++ b/libavformat/gif.c @@ -327,7 +327,7 @@ static int gif_write_header(AVFormatContext *s) video_enc = NULL; 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) video_enc = enc; } @@ -388,7 +388,7 @@ static int gif_write_video(AVFormatContext *s, 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) return 0; /* just ignore audio */ else diff --git a/libavformat/gifdec.c b/libavformat/gifdec.c index 90c6fc68e2..429a30cee5 100644 --- a/libavformat/gifdec.c +++ b/libavformat/gifdec.c @@ -555,14 +555,14 @@ static int gif_read_header(AVFormatContext * s1, if (!st) return -1; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.time_base.den = 5; - st->codec.time_base.num = 1; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->time_base.den = 5; + st->codec->time_base.num = 1; /* XXX: check if screen size is always valid */ - st->codec.width = s->screen_width; - st->codec.height = s->screen_height; - st->codec.pix_fmt = PIX_FMT_RGB24; + st->codec->width = s->screen_width; + st->codec->height = s->screen_height; + st->codec->pix_fmt = PIX_FMT_RGB24; return 0; } diff --git a/libavformat/grab.c b/libavformat/grab.c index e7c4262565..d72211c13a 100644 --- a/libavformat/grab.c +++ b/libavformat/grab.c @@ -109,11 +109,11 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) } desired_palette = -1; - if (st->codec.pix_fmt == PIX_FMT_YUV420P) { + if (st->codec->pix_fmt == PIX_FMT_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; - } else if (st->codec.pix_fmt == PIX_FMT_BGR24) { + } else if (st->codec->pix_fmt == PIX_FMT_BGR24) { desired_palette = VIDEO_PALETTE_RGB24; } @@ -245,15 +245,15 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) switch(s->frame_format) { case VIDEO_PALETTE_YUV420P: frame_size = (width * height * 3) / 2; - st->codec.pix_fmt = PIX_FMT_YUV420P; + st->codec->pix_fmt = PIX_FMT_YUV420P; break; case VIDEO_PALETTE_YUV422: frame_size = width * height * 2; - st->codec.pix_fmt = PIX_FMT_YUV422; + st->codec->pix_fmt = PIX_FMT_YUV422; break; case VIDEO_PALETTE_RGB24: 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; default: goto fail; @@ -261,12 +261,12 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->fd = video_fd; s->frame_size = frame_size; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.width = width; - st->codec.height = height; - st->codec.time_base.den = frame_rate; - st->codec.time_base.num = frame_rate_base; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->width = width; + st->codec->height = height; + st->codec->time_base.den = frame_rate; + st->codec->time_base.num = frame_rate_base; return 0; fail: diff --git a/libavformat/idcin.c b/libavformat/idcin.c index aecc1098dd..ce56d2a8a5 100644 --- a/libavformat/idcin.c +++ b/libavformat/idcin.c @@ -156,20 +156,20 @@ static int idcin_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); idcin->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_IDCIN; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = width; - st->codec.height = height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_IDCIN; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = width; + st->codec->height = height; /* load up the Huffman tables into extradata */ - st->codec.extradata_size = HUFFMAN_TABLE_SIZE; - st->codec.extradata = av_malloc(HUFFMAN_TABLE_SIZE); - if (get_buffer(pb, st->codec.extradata, HUFFMAN_TABLE_SIZE) != + st->codec->extradata_size = HUFFMAN_TABLE_SIZE; + st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE); + if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) != HUFFMAN_TABLE_SIZE) return AVERROR_IO; /* 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) { @@ -179,17 +179,17 @@ static int idcin_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); idcin->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = 1; - st->codec.channels = channels; - st->codec.sample_rate = sample_rate; - st->codec.bits_per_sample = bytes_per_sample * 8; - st->codec.bit_rate = sample_rate * bytes_per_sample * 8 * channels; - st->codec.block_align = bytes_per_sample * channels; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = 1; + st->codec->channels = channels; + st->codec->sample_rate = sample_rate; + st->codec->bits_per_sample = bytes_per_sample * 8; + st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels; + st->codec->block_align = bytes_per_sample * channels; if (bytes_per_sample == 1) - st->codec.codec_id = CODEC_ID_PCM_U8; + st->codec->codec_id = CODEC_ID_PCM_U8; else - st->codec.codec_id = CODEC_ID_PCM_S16LE; + st->codec->codec_id = CODEC_ID_PCM_S16LE; if (sample_rate % 14 != 0) { idcin->audio_chunk_size1 = (sample_rate / 14) * diff --git a/libavformat/idroq.c b/libavformat/idroq.c index add882eef3..62536b0b6b 100644 --- a/libavformat/idroq.c +++ b/libavformat/idroq.c @@ -145,11 +145,11 @@ static int roq_read_header(AVFormatContext *s, /* set the pts reference (1 pts = 1/90000) */ av_set_pts_info(st, 33, 1, 90000); roq->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_ROQ; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = roq->width; - st->codec.height = roq->height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_ROQ; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = roq->width; + st->codec->height = roq->height; if (roq->audio_channels) { st = av_new_stream(s, 0); @@ -157,15 +157,15 @@ static int roq_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); roq->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ROQ_DPCM; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = roq->audio_channels; - st->codec.sample_rate = RoQ_AUDIO_SAMPLE_RATE; - st->codec.bits_per_sample = 16; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ROQ_DPCM; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = roq->audio_channels; + st->codec->sample_rate = RoQ_AUDIO_SAMPLE_RATE; + st->codec->bits_per_sample = 16; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; } return 0; diff --git a/libavformat/img.c b/libavformat/img.c index c30d455d8a..b30e78eb14 100644 --- a/libavformat/img.c +++ b/libavformat/img.c @@ -134,9 +134,9 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) s->is_pipe = 1; if (!ap || !ap->time_base.num) { - st->codec.time_base= (AVRational){1,25}; + st->codec->time_base= (AVRational){1,25}; } else { - st->codec.time_base= ap->time_base; + st->codec->time_base= ap->time_base; } if (!s->is_pipe) { @@ -166,11 +166,11 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) url_fseek(f, 0, SEEK_SET); } - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.width = s->width; - st->codec.height = s->height; - st->codec.pix_fmt = s->pix_fmt; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->width = s->width; + st->codec->height = s->height; + st->codec->pix_fmt = s->pix_fmt; s->img_size = avpicture_get_size(s->pix_fmt, (s->width+15)&(~15), (s->height+15)&(~15)); return 0; @@ -232,7 +232,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) } else { /* XXX: computing this pts is not necessary as it is done in 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_number++; return 0; @@ -276,7 +276,7 @@ static int img_set_parameters(AVFormatContext *s, AVFormatParameters *ap) return -1; img->img_fmt = img_fmt; img->pix_fmt = i; - st->codec.pix_fmt = img->pix_fmt; + st->codec->pix_fmt = img->pix_fmt; return 0; } @@ -306,8 +306,8 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt) char filename[1024]; AVImageInfo info; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; picture = (AVPicture *)pkt->data; @@ -323,7 +323,7 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt) } info.width = width; 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.pict = *picture; ret = av_write_image(pb, img->img_fmt, &info); diff --git a/libavformat/img2.c b/libavformat/img2.c index 2214a1e9e5..dfc8404f45 100644 --- a/libavformat/img2.c +++ b/libavformat/img2.c @@ -193,8 +193,8 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) } if(ap && ap->width && ap->height){ - st->codec.width = ap->width; - st->codec.height= ap->height; + st->codec->width = ap->width; + st->codec->height= ap->height; } if (!s->is_pipe) { @@ -209,17 +209,17 @@ static int img_read_header(AVFormatContext *s1, AVFormatParameters *ap) } if(ap->video_codec_id){ - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = ap->video_codec_id; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = ap->video_codec_id; }else if(ap->audio_codec_id){ - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = ap->audio_codec_id; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = ap->audio_codec_id; }else{ - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = av_str2id(img_tags, s->path); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = av_str2id(img_tags, s->path); } - if(st->codec.codec_type == CODEC_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE) - st->codec.pix_fmt = ap->pix_fmt; + if(st->codec->codec_type == CODEC_TYPE_VIDEO && ap->pix_fmt != PIX_FMT_NONE) + st->codec->pix_fmt = ap->pix_fmt; return 0; } @@ -231,7 +231,7 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt) int i; int size[3]={0}, ret[3]={0}; 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) { /* loop over input */ @@ -314,7 +314,7 @@ static int img_write_packet(AVFormatContext *s, AVPacket *pkt) VideoData *img = s->priv_data; ByteIOContext pb1[3], *pb[3]= {&pb1[0], &pb1[1], &pb1[2]}; char filename[1024]; - AVCodecContext *codec= &s->streams[ pkt->stream_index ]->codec; + AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; int i; if (!img->is_pipe) { diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c index f2f0e9e2c1..c62a007473 100644 --- a/libavformat/ipmovie.c +++ b/libavformat/ipmovie.c @@ -554,14 +554,14 @@ static int ipmovie_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); ipmovie->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_INTERPLAY_VIDEO; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = ipmovie->video_width; - st->codec.height = ipmovie->video_height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_INTERPLAY_VIDEO; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = ipmovie->video_width; + st->codec->height = ipmovie->video_height; /* palette considerations */ - st->codec.palctrl = &ipmovie->palette_control; + st->codec->palctrl = &ipmovie->palette_control; if (ipmovie->audio_type) { st = av_new_stream(s, 0); @@ -569,17 +569,17 @@ static int ipmovie_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); ipmovie->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = ipmovie->audio_type; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = ipmovie->audio_channels; - st->codec.sample_rate = ipmovie->audio_sample_rate; - st->codec.bits_per_sample = ipmovie->audio_bits; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - if (st->codec.codec_id == CODEC_ID_INTERPLAY_DPCM) - st->codec.bit_rate /= 2; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = ipmovie->audio_type; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = ipmovie->audio_channels; + st->codec->sample_rate = ipmovie->audio_sample_rate; + st->codec->bits_per_sample = ipmovie->audio_bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM) + st->codec->bit_rate /= 2; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; } return 0; diff --git a/libavformat/matroska.c b/libavformat/matroska.c index 0cb1efc636..0661151487 100644 --- a/libavformat/matroska.c +++ b/libavformat/matroska.c @@ -2273,46 +2273,46 @@ matroska_read_header (AVFormatContext *s, return AVERROR_NOMEM; 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){ - st->codec.extradata = extradata; - st->codec.extradata_size = extradata_size; + st->codec->extradata = extradata; + st->codec->extradata_size = extradata_size; } else if(track->codec_priv && track->codec_priv_size > 0){ - st->codec.extradata = av_malloc(track->codec_priv_size); - if(st->codec.extradata == NULL) + st->codec->extradata = av_malloc(track->codec_priv_size); + if(st->codec->extradata == NULL) return AVERROR_NOMEM; - st->codec.extradata_size = track->codec_priv_size; - memcpy(st->codec.extradata, track->codec_priv, + st->codec->extradata_size = track->codec_priv_size; + memcpy(st->codec->extradata, track->codec_priv, track->codec_priv_size); } if (track->type == MATROSKA_TRACK_TYPE_VIDEO) { MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_tag = videotrack->fourcc; - st->codec.width = videotrack->pixel_width; - st->codec.height = videotrack->pixel_height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_tag = videotrack->fourcc; + st->codec->width = videotrack->pixel_width; + st->codec->height = videotrack->pixel_height; if (videotrack->display_width == 0) - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->pixel_width; else - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->display_width; if (videotrack->display_height == 0) - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->pixel_height; else - st->codec.sample_aspect_ratio.num = + st->codec->sample_aspect_ratio.num = videotrack->display_height; } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.sample_rate = audiotrack->samplerate; - st->codec.channels = audiotrack->channels; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->sample_rate = audiotrack->samplerate; + st->codec->channels = audiotrack->channels; } /* 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++) { - av_free(s->streams[n]->codec.extradata); + av_free(s->streams[n]->codec->extradata); } memset(matroska, 0, sizeof(MatroskaDemuxContext)); diff --git a/libavformat/mmf.c b/libavformat/mmf.c index 568f0ac0f1..82d70170bc 100644 --- a/libavformat/mmf.c +++ b/libavformat/mmf.c @@ -61,9 +61,9 @@ static int mmf_write_header(AVFormatContext *s) offset_t pos; 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) { - 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; } @@ -96,7 +96,7 @@ static int mmf_write_header(AVFormatContext *s) 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); @@ -144,7 +144,7 @@ static int mmf_write_trailer(AVFormatContext *s) /* "play wav" */ put_byte(pb, 0); /* start time */ 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 */ /* "nop" */ @@ -239,14 +239,14 @@ static int mmf_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_YAMAHA; - st->codec.sample_rate = rate; - st->codec.channels = 1; - st->codec.bits_per_sample = 4; - st->codec.bit_rate = st->codec.sample_rate * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_YAMAHA; + st->codec->sample_rate = rate; + st->codec->channels = 1; + st->codec->bits_per_sample = 4; + 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; } diff --git a/libavformat/mov.c b/libavformat/mov.c index 63529ce9bf..6b1d333e74 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -481,16 +481,16 @@ static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) /* helps parsing the string hereafter... */ c->mp4 = 0; 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')) - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; } else if(ctype == 0) { /* MP4 */ /* helps parsing the string hereafter... */ c->mp4 = 1; 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')) - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; } get_be32(pb); /* component manufacture */ get_be32(pb); /* component flags */ @@ -591,10 +591,10 @@ static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) #ifdef DEBUG av_log(NULL, AV_LOG_DEBUG, "Specific MPEG4 header len=%d\n", len); #endif - st->codec.extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); - if (st->codec.extradata) { - get_buffer(pb, st->codec.extradata, len); - st->codec.extradata_size = len; + st->codec->extradata = (uint8_t*) av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); + if (st->codec->extradata) { + get_buffer(pb, st->codec->extradata, 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 // this should be fixed and just SMI header should be passed - av_free(st->codec.extradata); - st->codec.extradata_size = 0x5a + atom.size; - st->codec.extradata = (uint8_t*) av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - - if (st->codec.extradata) { - strcpy(st->codec.extradata, "SVQ3"); // fake - 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_free(st->codec->extradata); + st->codec->extradata_size = 0x5a + atom.size; + st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + + if (st->codec->extradata) { + strcpy(st->codec->extradata, "SVQ3"); // fake + 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); } else 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)) return -1; - av_free(st->codec.extradata); + av_free(st->codec->extradata); - 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_size = atom.size; + st->codec->extradata = (uint8_t*) av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (st->codec.extradata) { - get_buffer(pb, st->codec.extradata, atom.size); + if (st->codec->extradata) { + get_buffer(pb, st->codec->extradata, atom.size); } else url_fskip(pb, atom.size); @@ -829,7 +829,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) AVCodec *codec; codec = avcodec_find_decoder(id); if (codec) - st->codec.codec_type = codec->type; + st->codec->codec_type = codec->type; } #ifdef DEBUG 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 >> 16) & 0xff, (format >> 24) & 0xff, - st->codec.codec_type); + st->codec->codec_type); #endif - st->codec.codec_tag = format; - if(st->codec.codec_type==CODEC_TYPE_VIDEO) { + st->codec->codec_tag = format; + if(st->codec->codec_type==CODEC_TYPE_VIDEO) { MOV_atom_t a = { 0, 0, 0 }; - st->codec.codec_id = id; + st->codec->codec_id = id; get_be16(pb); /* version */ get_be16(pb); /* revision level */ get_be32(pb); /* vendor */ get_be32(pb); /* temporal 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); }else{ - st->codec.width = get_be16(pb); /* width */ - st->codec.height = get_be16(pb); /* height */ + st->codec->width = get_be16(pb); /* width */ + st->codec->height = get_be16(pb); /* height */ } get_be32(pb); /* horiz resolution */ get_be32(pb); /* vert resolution */ @@ -865,16 +865,16 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) #endif get_buffer(pb, codec_name, 32); /* codec name, pascal string (FIXME: true for mp4?) */ if (codec_name[0] <= 31) { - memcpy(st->codec.codec_name, &codec_name[1],codec_name[0]); - st->codec.codec_name[codec_name[0]] = 0; + memcpy(st->codec->codec_name, &codec_name[1],codec_name[0]); + st->codec->codec_name[codec_name[0]] = 0; } - st->codec.bits_per_sample = get_be16(pb); /* depth */ - st->codec.color_table_id = get_be16(pb); /* colortable id */ + st->codec->bits_per_sample = get_be16(pb); /* depth */ + st->codec->color_table_id = get_be16(pb); /* colortable id */ /* These are set in mov_read_stts and might already be set! - st->codec.time_base.den = 25; - st->codec.time_base.num = 1; + st->codec->time_base.den = 25; + st->codec->time_base.num = 1; */ size -= (16+8*4+2+32+2*2); #if 0 @@ -948,8 +948,8 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) #else /* figure out the palette situation */ - color_depth = st->codec.bits_per_sample & 0x1F; - color_greyscale = st->codec.bits_per_sample & 0x20; + color_depth = st->codec->bits_per_sample & 0x1F; + color_greyscale = st->codec->bits_per_sample & 0x20; /* if the depth is 2, 4, or 8 bpp, file is palettized */ 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; } - } 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 */ 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->palette_changed = 1; + st->codec->palctrl = &c->palette_control; + st->codec->palctrl->palette_changed = 1; } else - st->codec.palctrl = NULL; + st->codec->palctrl = NULL; a.size = size; mov_read_default(c, pb, a); #endif } else { - 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 + 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 { #ifdef DEBUG 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 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.channels=1; + st->codec->sample_rate=8000; + st->codec->channels=1; } else //AMR-WB { - st->codec.sample_rate=16000; - st->codec.channels=1; + st->codec->sample_rate=16000; + st->codec->channels=1; } - st->codec.bits_per_sample=16; - st->codec.bit_rate=0; /*It is not possible to tell this before we have + st->codec->bits_per_sample=16; + 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*/ } - 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! //Do some mp4 auto detect. @@ -1067,7 +1067,7 @@ static int mov_read_stsd(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) size-=(16); 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; 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*/ get_be16(pb); /*revesion*/ get_be32(pb); - st->codec.channels = get_be16(pb); /* channels */ - st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ + st->codec->channels = get_be16(pb); /* channels */ + st->codec->bits_per_sample = get_be16(pb); /* bits per sample */ 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); 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); /* Get correct sample rate from extradata */ - if(st->codec.extradata_size) { + if(st->codec->extradata_size) { const int samplerate_table[] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 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 int samplerate_index = ((px[0] & 7) << 1) + ((px[1] >> 7) & 1); - st->codec.sample_rate = samplerate_table[samplerate_index]; - st->codec.channels = (px[1] >> 3) & 15; + st->codec->sample_rate = samplerate_table[samplerate_index]; + 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 */ get_be32(pb); /* version */ get_be32(pb); - st->codec.channels = get_be16(pb); /* channels */ - st->codec.bits_per_sample = get_be16(pb); /* bits per sample */ + st->codec->channels = get_be16(pb); /* channels */ + st->codec->bits_per_sample = get_be16(pb); /* bits per sample */ get_be32(pb); - st->codec.sample_rate = get_be16(pb); + st->codec->sample_rate = get_be16(pb); get_be16(pb); /* fetch the 36-byte extradata needed for alac decoding */ - st->codec.extradata_size = 36; - st->codec.extradata = (uint8_t*) - av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size = 36; + st->codec->extradata = (uint8_t*) + av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } else if(size>=(16+20)) {//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_be32(pb); /* vendor */ - st->codec.channels = get_be16(pb); /* channel count */ - st->codec.bits_per_sample = get_be16(pb); /* sample size */ + st->codec->channels = get_be16(pb); /* channel count */ + st->codec->bits_per_sample = get_be16(pb); /* sample size */ /* handle specific s8 codec */ get_be16(pb); /* compression id = 0*/ get_be16(pb); /* packet size = 0 */ - 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); + 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); - switch (st->codec.codec_id) { + switch (st->codec->codec_id) { case CODEC_ID_PCM_S16BE: - if (st->codec.bits_per_sample == 8) - st->codec.codec_id = CODEC_ID_PCM_S8; + if (st->codec->bits_per_sample == 8) + st->codec->codec_id = CODEC_ID_PCM_S8; /* fall */ case CODEC_ID_PCM_U8: - st->codec.bit_rate = st->codec.sample_rate * 8; + st->codec->bit_rate = st->codec->sample_rate * 8; break; 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); -// st->codec.time_base.num = 1; -// st->codec.time_base.den = c->streams[c->fc->nb_streams-1]->time_scale; +// st->codec->time_base.num = 1; +// st->codec->time_base.den = c->streams[c->fc->nb_streams-1]->time_scale; st->nb_frames= total_sample_count; if(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; 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 */ 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 */ /* those are fixed-point */ - /*st->codec.width =*/ get_be32(pb) >> 16; /* track width */ - /*st->codec.height =*/ get_be32(pb) >> 16; /* track height */ + /*st->codec->width =*/ get_be32(pb) >> 16; /* track width */ + /*st->codec->height =*/ get_be32(pb) >> 16; /* track height */ return 0; } @@ -1755,7 +1755,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) #if 1 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]); for(j=i+1; j<s->nb_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 // (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)) foundsize=(sc->sample_to_chunk[i].count*cod->channels*cod->bits_per_sample)/8; else diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 8b41232a63..912fa4b21c 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1256,11 +1256,11 @@ int mov_write_ftyp_tag(ByteIOContext *pb, AVFormatContext *s) static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) { - 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 AudioRate = s->streams[1]->codec->sample_rate; + int FrameRate = ((s->streams[0]->codec->time_base.den) * (0x10000))/ (s->streams[0]->codec->time_base.num); //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_tag(pb, "uuid"); @@ -1302,8 +1302,8 @@ static void mov_write_uuidprof_tag(ByteIOContext *pb, AVFormatContext *s) put_be32(pb, 0xc0 ); 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.height); + put_be16(pb, s->streams[0]->codec->width); + put_be16(pb, s->streams[0]->codec->height); put_be32(pb, 0x010001 ); } @@ -1314,7 +1314,7 @@ static int mov_write_header(AVFormatContext *s) int 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 (!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; 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]; int cl, id; unsigned int samplesInChunk = 0; diff --git a/libavformat/mp3.c b/libavformat/mp3.c index f86d976eb8..f45f852d58 100644 --- a/libavformat/mp3.c +++ b/libavformat/mp3.c @@ -251,8 +251,8 @@ static int mp3_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_MP3; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_MP3; st->need_parsing = 1; /* try to get the TAG */ diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 9404df0c26..a597495ef4 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -360,26 +360,26 @@ static int mpeg_mux_init(AVFormatContext *ctx) av_set_pts_info(st, 64, 1, 90000); - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: - if (st->codec.codec_id == CODEC_ID_AC3) { + if (st->codec->codec_id == CODEC_ID_AC3) { 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++; - } else if (st->codec.codec_id == CODEC_ID_PCM_S16BE) { + } else if (st->codec->codec_id == CODEC_ID_PCM_S16BE) { stream->id = lpcm_id++; 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; } if (j == 4) goto fail; - if (st->codec.channels > 8) + if (st->codec->channels > 8) return -1; 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_align = st->codec.channels * 2; + stream->lpcm_align = st->codec->channels * 2; } else { stream->id = mpa_id++; } @@ -391,8 +391,8 @@ static int mpeg_mux_init(AVFormatContext *ctx) break; case CODEC_TYPE_VIDEO: stream->id = mpv_id++; - if (st->codec.rc_buffer_size) - stream->max_buffer_size = 6*1024 + st->codec.rc_buffer_size/8; + if (st->codec->rc_buffer_size) + stream->max_buffer_size = 6*1024 + st->codec->rc_buffer_size/8; else stream->max_buffer_size = 230*1024; //FIXME this is probably too small as default #if 0 @@ -422,10 +422,10 @@ static int mpeg_mux_init(AVFormatContext *ctx) st = ctx->streams[i]; stream = (StreamInfo*) st->priv_data; - if(st->codec.rc_max_rate || stream->id==VIDEO_ID) - codec_rate= st->codec.rc_max_rate; + if(st->codec->rc_max_rate || stream->id==VIDEO_ID) + codec_rate= st->codec->rc_max_rate; else - codec_rate= st->codec.bit_rate; + codec_rate= st->codec->bit_rate; if(!codec_rate) codec_rate= (1<<21)*8*50/ctx->nb_streams; @@ -1073,7 +1073,7 @@ retry: /* for subtitle, a single PES packet must be generated, so we flush after every single subtitle packet */ if(s->packet_size > avail_data && !flush - && st->codec.codec_type != CODEC_TYPE_SUBTITLE) + && st->codec->codec_type != CODEC_TYPE_SUBTITLE) return 0; if(avail_data==0) continue; @@ -1183,7 +1183,7 @@ static int mpeg_mux_write_packet(AVFormatContext *ctx, AVPacket *pkt) int64_t pts, dts; PacketDesc *pkt_desc; 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; dts= pkt->dts; @@ -1634,8 +1634,8 @@ static int mpegps_read_packet(AVFormatContext *s, st = av_new_stream(s, startcode); if (!st) goto skip; - st->codec.codec_type = type; - st->codec.codec_id = codec_id; + st->codec->codec_type = type; + st->codec->codec_id = codec_id; if (codec_id != CODEC_ID_PCM_S16BE) st->need_parsing = 1; found: @@ -1653,9 +1653,9 @@ static int mpegps_read_packet(AVFormatContext *s, get_byte(&s->pb); /* dynamic range control (0x80 = off) */ len -= 3; freq = (b1 >> 4) & 3; - st->codec.sample_rate = lpcm_freq_tab[freq]; - st->codec.channels = 1 + (b1 & 7); - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * 2; + st->codec->sample_rate = lpcm_freq_tab[freq]; + st->codec->channels = 1 + (b1 & 7); + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * 2; } av_new_packet(pkt, len); get_buffer(&s->pb, pkt->data, pkt->size); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 91f6f4f753..0e15f551cf 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -493,7 +493,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len) } 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) { av_set_pts_info(st, 33, 1, 90000); st->priv_data = pes; - st->codec.codec_type = codec_type; - st->codec.codec_id = codec_id; + st->codec->codec_type = codec_type; + st->codec->codec_id = codec_id; st->need_parsing = 1; pes->st = st; } @@ -1253,8 +1253,8 @@ static int mpegts_read_header(AVFormatContext *s, if (!st) goto fail; av_set_pts_info(st, 60, 1, 27000000); - st->codec.codec_type = CODEC_TYPE_DATA; - st->codec.codec_id = CODEC_ID_MPEG2TS; + st->codec->codec_type = CODEC_TYPE_DATA; + st->codec->codec_id = CODEC_ID_MPEG2TS; /* we iterate until we find two PCRs to estimate the bitrate */ 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->cur_pcr = pcrs[0] - ts->pcr_incr * packet_count[0]; 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; #if 0 printf("start=%0.3f pcr=%0.3f incr=%d\n", diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 1463abea78..4fe8f3e15c 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -262,7 +262,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) for(i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; MpegTSWriteStream *ts_st = st->priv_data; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: stream_type = STREAM_TYPE_VIDEO_MPEG2; @@ -293,7 +293,7 @@ static void mpegts_write_pmt(AVFormatContext *s, MpegTSService *service) q += 2; /* patched after */ /* write optional descriptors here */ - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_AUDIO: if (strlen(st->language) == 3) { *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->payload_pts = AV_NOPTS_VALUE; /* 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 = 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 */ @@ -570,15 +570,15 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, *q++ = 0x00; *q++ = 0x01; private_code = 0; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { *q++ = 0xe0; - } else if (st->codec.codec_type == CODEC_TYPE_AUDIO && - (st->codec.codec_id == CODEC_ID_MP2 || - st->codec.codec_id == CODEC_ID_MP3)) { + } else if (st->codec->codec_type == CODEC_TYPE_AUDIO && + (st->codec->codec_id == CODEC_ID_MP2 || + st->codec->codec_id == CODEC_ID_MP3)) { *q++ = 0xc0; } else { *q++ = 0xbd; - if (st->codec.codec_type == CODEC_TYPE_SUBTITLE) { + if (st->codec->codec_type == CODEC_TYPE_SUBTITLE) { private_code = 0x20; } } @@ -593,7 +593,7 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st, *q++ = len; val = 0x80; /* 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; *q++ = val; if (pts != AV_NOPTS_VALUE) { @@ -660,7 +660,7 @@ static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) MpegTSWriteStream *ts_st = st->priv_data; 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 */ mpegts_write_pes(s, st, buf, size, pkt->pts); return 0; diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 91c2aabe69..27c7abc8cc 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -439,12 +439,12 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) if (!nst) goto fail; st->priv_data = nst; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_tag = vtag; - st->codec.codec_id = codec_get_id(nsv_codec_video_tags, vtag); - st->codec.width = vwidth; - st->codec.height = vheight; - st->codec.bits_per_sample = 24; /* depth XXX */ + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_tag = vtag; + st->codec->codec_id = codec_get_id(nsv_codec_video_tags, vtag); + st->codec->width = vwidth; + st->codec->height = vheight; + st->codec->bits_per_sample = 24; /* depth XXX */ av_set_pts_info(st, 64, framerate.den, framerate.num); st->start_time = 0; @@ -460,17 +460,17 @@ static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) if (!nst) goto fail; st->priv_data = nst; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = atag; - st->codec.codec_id = codec_get_id(nsv_codec_audio_tags, atag); + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = atag; + st->codec->codec_id = codec_get_id(nsv_codec_audio_tags, atag); st->start_time = 0; // st->duration = nsv->duration; //FIXME st->need_parsing = 1; /* for PCM we will read a chunk later and put correct info */ /* XXX:FIXME */ - //st->codec.channels = 2; //XXX:channels; - //st->codec.sample_rate = 1000; - //av_set_pts_info(st, 64, 1, st->codec.sample_rate); + //st->codec->channels = 2; //XXX:channels; + //st->codec->sample_rate = 1000; + //av_set_pts_info(st, 64, 1, st->codec->sample_rate); #endif } @@ -606,7 +606,7 @@ null_chunk_retry: pkt = &nsv->ahead[NSV_ST_AUDIO]; /* read raw audio specific header on the first audio chunk... */ /* 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 channels; uint16_t samplerate; @@ -622,13 +622,13 @@ null_chunk_retry: } bps /= channels; // ??? 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 */ channels = 1; - st[NSV_ST_AUDIO]->codec.channels = channels; - st[NSV_ST_AUDIO]->codec.sample_rate = samplerate; + st[NSV_ST_AUDIO]->codec->channels = channels; + st[NSV_ST_AUDIO]->codec->sample_rate = samplerate; 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)); } } @@ -704,8 +704,8 @@ static int nsv_read_close(AVFormatContext *s) av_free(ast->index_entries); av_free(ast); } - av_free(st->codec.extradata); - av_free(st->codec.palctrl); + av_free(st->codec->extradata); + av_free(st->codec->palctrl); } #endif diff --git a/libavformat/nut.c b/libavformat/nut.c index fe3b6df104..cd46d55d75 100644 --- a/libavformat/nut.c +++ b/libavformat/nut.c @@ -155,7 +155,7 @@ static void build_frame_code(AVFormatContext *s){ for(stream_id= 0; stream_id<s->nb_streams; stream_id++){ int start2= start + (end-start)*stream_id / 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 intra_only= /*codec->intra_only || */is_audio; int pred_count; @@ -579,7 +579,7 @@ static int nut_write_header(AVFormatContext *s) { int nom, denom, ssize; - codec = &s->streams[i]->codec; + codec = s->streams[i]->codec; put_be64(bc, STREAM_STARTCODE); 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); } /* 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_str(bc, LIBAVFORMAT_IDENT); } @@ -707,7 +707,7 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) int size= pkt->size; 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); frame_type=0; @@ -949,27 +949,27 @@ static int decode_stream_header(NUTContext *nut){ class = get_v(bc); tmp = get_vb(bc); - st->codec.codec_tag= tmp; + st->codec->codec_tag= tmp; switch(class) { case 0: - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = codec_get_bmp_id(tmp); - if (st->codec.codec_id == CODEC_ID_NONE) + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = codec_get_bmp_id(tmp); + if (st->codec->codec_id == CODEC_ID_NONE) av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); break; case 1: case 32: //compatibility - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = codec_get_wav_id(tmp); - if (st->codec.codec_id == CODEC_ID_NONE) + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = codec_get_wav_id(tmp); + if (st->codec->codec_id == CODEC_ID_NONE) av_log(s, AV_LOG_ERROR, "Unknown codec?!\n"); break; case 2: -// st->codec.codec_type = CODEC_TYPE_TEXT; +// st->codec->codec_type = CODEC_TYPE_TEXT; // break; case 3: - st->codec.codec_type = CODEC_TYPE_DATA; + st->codec->codec_type = CODEC_TYPE_DATA; break; default: 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); denom = 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); get_byte(bc); /* flags */ /* codec specific data headers */ while(get_v(bc) != 0){ - st->codec.extradata_size= get_v(bc); - if((unsigned)st->codec.extradata_size > (1<<30)) + st->codec->extradata_size= get_v(bc); + if((unsigned)st->codec->extradata_size > (1<<30)) return -1; - st->codec.extradata= av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); - get_buffer(bc, st->codec.extradata, st->codec.extradata_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); // 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.height = get_v(bc); - st->codec.sample_aspect_ratio.num= get_v(bc); - st->codec.sample_aspect_ratio.den= get_v(bc); + st->codec->width = get_v(bc); + st->codec->height = get_v(bc); + st->codec->sample_aspect_ratio.num= get_v(bc); + st->codec->sample_aspect_ratio.den= get_v(bc); 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 - st->codec.channels = get_v(bc); + st->codec->channels = get_v(bc); } if(check_checksum(bc)){ 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; 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); diff --git a/libavformat/ogg.c b/libavformat/ogg.c index ab47d029a5..b2767a22d5 100644 --- a/libavformat/ogg.c +++ b/libavformat/ogg.c @@ -39,7 +39,7 @@ static int ogg_write_header(AVFormatContext *avfcontext) ogg_stream_init(&context->os, 31415); 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; 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) { 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_page og ; int64_t pts; diff --git a/libavformat/ogg2.c b/libavformat/ogg2.c index aee6d58909..b32e27d3ab 100644 --- a/libavformat/ogg2.c +++ b/libavformat/ogg2.c @@ -430,7 +430,7 @@ ogg_gptopts (AVFormatContext * s, int i, uint64_t gp) ogg_t *ogg = s->priv_data; ogg_stream_t *os = ogg->streams + i; AVStream *st = s->streams[i]; - AVCodecContext *codec = &st->codec; + AVCodecContext *codec = st->codec; uint64_t pts = AV_NOPTS_VALUE; if(os->codec->gptopts){ @@ -537,7 +537,7 @@ ogg_read_close (AVFormatContext * s) for (i = 0; i < ogg->nstreams; i++){ av_free (ogg->streams[i].buf); av_free (ogg->streams[i].private); - av_freep (&s->streams[i]->codec.extradata); + av_freep (&s->streams[i]->codec->extradata); } av_free (ogg->streams); return 0; diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c index 9ad362830d..dc80065cfd 100644 --- a/libavformat/oggparseflac.c +++ b/libavformat/oggparseflac.c @@ -52,17 +52,17 @@ flac_header (AVFormatContext * s, int idx) skip_bits(&gb, 16*2+24*2); - st->codec.sample_rate = get_bits_long(&gb, 20); - st->codec.channels = get_bits(&gb, 3) + 1; + st->codec->sample_rate = get_bits_long(&gb, 20); + st->codec->channels = get_bits(&gb, 3) + 1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_FLAC; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_FLAC; - st->codec.extradata = + st->codec->extradata = 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); - st->codec.extradata_size = FLAC_STREAMINFO_SIZE; + st->codec->extradata_size = FLAC_STREAMINFO_SIZE; } else if (mdt == 4) { vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4); } diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c index 8927822570..299eb4e506 100644 --- a/libavformat/oggparsetheora.c +++ b/libavformat/oggparsetheora.c @@ -40,7 +40,7 @@ theora_header (AVFormatContext * s, int idx) ogg_stream_t *os = ogg->streams + idx; AVStream *st = s->streams[idx]; 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; if(!(os->buf[os->pstart] & 0x80)) @@ -62,33 +62,33 @@ theora_header (AVFormatContext * s, int idx) return -1; skip_bits(&gb, 8); /* revision */ - st->codec.width = get_bits(&gb, 16) << 4; - st->codec.height = get_bits(&gb, 16) << 4; + st->codec->width = get_bits(&gb, 16) << 4; + st->codec->height = get_bits(&gb, 16) << 4; skip_bits(&gb, 64); - st->codec.time_base.den = get_bits(&gb, 32); - st->codec.time_base.num = get_bits(&gb, 32); + st->codec->time_base.den = 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.den = get_bits(&gb, 24); + st->codec->sample_aspect_ratio.num = get_bits(&gb, 24); + st->codec->sample_aspect_ratio.den = get_bits(&gb, 24); skip_bits(&gb, 38); thp->gpshift = get_bits(&gb, 5); thp->gpmask = (1 << thp->gpshift) - 1; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_THEORA; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_THEORA; } else if (os->buf[os->pstart] == 0x83) { vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); } - st->codec.extradata = av_realloc (st->codec.extradata, cds); - cdp = st->codec.extradata + st->codec.extradata_size; + st->codec->extradata = av_realloc (st->codec->extradata, cds); + cdp = st->codec->extradata + st->codec->extradata_size; *cdp++ = os->psize >> 8; *cdp++ = os->psize & 0xff; memcpy (cdp, os->buf + os->pstart, os->psize); - st->codec.extradata_size = cds; + st->codec->extradata_size = cds; return 1; } @@ -103,8 +103,8 @@ theora_gptopts(AVFormatContext *ctx, int idx, uint64_t gp) uint64_t iframe = gp >> thp->gpshift; uint64_t pframe = gp & thp->gpmask; - return (iframe + pframe) * AV_TIME_BASE * st->codec.time_base.num / - st->codec.time_base.den; + return (iframe + pframe) * AV_TIME_BASE * st->codec->time_base.num / + st->codec->time_base.den; } ogg_codec_t theora_codec = { diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c index 877b1a9a8a..f9f53fd552 100644 --- a/libavformat/oggparsevorbis.c +++ b/libavformat/oggparsevorbis.c @@ -178,19 +178,19 @@ vorbis_header (AVFormatContext * s, int idx) memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize); if (os->buf[os->pstart] == 1) { uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels - st->codec.channels = *p++; - st->codec.sample_rate = le2me_32 (unaligned32 (p)); + st->codec->channels = *p++; + st->codec->sample_rate = le2me_32 (unaligned32 (p)); 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_id = CODEC_ID_VORBIS; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_VORBIS; } else if (os->buf[os->pstart] == 3) { vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); } else { - st->codec.extradata_size = - fixup_vorbis_headers(s, priv, &st->codec.extradata); + st->codec->extradata_size = + fixup_vorbis_headers(s, priv, &st->codec->extradata); } return os->seq < 3; diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c index c8c3b2915a..51afe1b5af 100644 --- a/libavformat/psxstr.c +++ b/libavformat/psxstr.c @@ -182,11 +182,11 @@ static int str_read_header(AVFormatContext *s, str->channels[channel].video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_MDEC; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = str->channels[channel].width; - st->codec.height = str->channels[channel].height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_MDEC; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = str->channels[channel].width; + st->codec->height = str->channels[channel].height; } break; @@ -212,13 +212,13 @@ static int str_read_header(AVFormatContext *s, str->channels[channel].audio_stream_index = st->index; fmt = sector[0x13]; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_XA; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.channels = (fmt&1)?2:1; - st->codec.sample_rate = (fmt&4)?18900:37800; - // st->codec.bit_rate = 0; //FIXME; - st->codec.block_align = 128; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_XA; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->channels = (fmt&1)?2:1; + st->codec->sample_rate = (fmt&4)?18900:37800; + // st->codec->bit_rate = 0; //FIXME; + st->codec->block_align = 128; } break; diff --git a/libavformat/raw.c b/libavformat/raw.c index abfce00d30..b1a5762f79 100644 --- a/libavformat/raw.c +++ b/libavformat/raw.c @@ -50,25 +50,25 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap) if (ap) { id = s->iformat->value; if (id == CODEC_ID_RAWVIDEO) { - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; } 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: - st->codec.sample_rate = ap->sample_rate; - st->codec.channels = ap->channels; - av_set_pts_info(st, 64, 1, st->codec.sample_rate); + st->codec->sample_rate = ap->sample_rate; + st->codec->channels = ap->channels; + av_set_pts_info(st, 64, 1, st->codec->sample_rate); break; case CODEC_TYPE_VIDEO: av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); - st->codec.width = ap->width; - st->codec.height = ap->height; - st->codec.pix_fmt = ap->pix_fmt; - if(st->codec.pix_fmt == PIX_FMT_NONE) - st->codec.pix_fmt= PIX_FMT_YUV420P; + st->codec->width = ap->width; + st->codec->height = ap->height; + st->codec->pix_fmt = ap->pix_fmt; + if(st->codec->pix_fmt == PIX_FMT_NONE) + st->codec->pix_fmt= PIX_FMT_YUV420P; break; default: return -1; @@ -133,24 +133,24 @@ int pcm_read_seek(AVFormatContext *s, int64_t pos; st = s->streams[0]; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: - block_align = 2 * st->codec.channels; - byte_rate = block_align * st->codec.sample_rate; + block_align = 2 * st->codec->channels; + byte_rate = block_align * st->codec->sample_rate; break; case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ALAW: - block_align = st->codec.channels; - byte_rate = block_align * st->codec.sample_rate; + block_align = st->codec->channels; + byte_rate = block_align * st->codec->sample_rate; break; default: - block_align = st->codec.block_align; - byte_rate = st->codec.bit_rate / 8; + block_align = st->codec->block_align; + byte_rate = st->codec->bit_rate / 8; break; } @@ -180,8 +180,8 @@ static int ac3_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_AC3; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_AC3; st->need_parsing = 1; /* the parameters will be extracted from the compressed bitstream */ return 0; @@ -195,8 +195,8 @@ static int shorten_read_header(AVFormatContext *s, st = av_new_stream(s, 0); if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_SHORTEN; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_SHORTEN; st->need_parsing = 1; /* the parameters will be extracted from the compressed bitstream */ return 0; @@ -212,8 +212,8 @@ static int dts_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_DTS; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_DTS; st->need_parsing = 1; /* the parameters will be extracted from the compressed bitstream */ return 0; @@ -229,17 +229,17 @@ static int video_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = s->iformat->value; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = s->iformat->value; st->need_parsing = 1; /* for mjpeg, specify frame rate */ /* for mpeg4 specify it too (most mpeg4 streams dont have the fixed_vop_rate set ...)*/ if (ap && ap->time_base.num) { av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); - } else if ( st->codec.codec_id == CODEC_ID_MJPEG || - st->codec.codec_id == CODEC_ID_MPEG4 || - st->codec.codec_id == CODEC_ID_H264) { + } else if ( st->codec->codec_id == CODEC_ID_MJPEG || + st->codec->codec_id == CODEC_ID_MPEG4 || + st->codec->codec_id == CODEC_ID_H264) { 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; AVStream *st = s->streams[0]; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + 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) return -1; diff --git a/libavformat/rm.c b/libavformat/rm.c index f0fe17974b..4568f4f1d2 100644 --- a/libavformat/rm.c +++ b/libavformat/rm.c @@ -298,7 +298,7 @@ static int rm_write_header(AVFormatContext *s) for(n=0;n<s->nb_streams;n++) { s->streams[n]->id = n; - codec = &s->streams[n]->codec; + codec = s->streams[n]->codec; stream = &rm->streams[n]; memset(stream, 0, sizeof(StreamInfo)); 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) { - if (s->streams[pkt->stream_index]->codec.codec_type == + if (s->streams[pkt->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO) return rm_write_audio(s, pkt->data, pkt->size, pkt->flags); 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_byte(pb); get_str8(pb, buf, sizeof(buf)); - st->codec.sample_rate = 8000; - st->codec.channels = 1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_RA_144; + st->codec->sample_rate = 8000; + st->codec->channels = 1; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_RA_144; } else { int flavor, sub_packet_h, coded_framesize; /* old version (4) */ @@ -512,30 +512,30 @@ static void rm_read_audio_stream_info(AVFormatContext *s, AVStream *st, get_be32(pb); /* ??? */ get_be32(pb); /* ??? */ 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); /* ??? */ - st->codec.sample_rate = get_be16(pb); + st->codec->sample_rate = get_be16(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 */ - st->codec.codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_type = CODEC_TYPE_AUDIO; if (!strcmp(buf, "dnet")) { - st->codec.codec_id = CODEC_ID_AC3; + st->codec->codec_id = CODEC_ID_AC3; } else if (!strcmp(buf, "28_8")) { - st->codec.codec_id = CODEC_ID_RA_288; - st->codec.extradata_size= 10; - st->codec.extradata= av_mallocz(st->codec.extradata_size); + st->codec->codec_id = CODEC_ID_RA_288; + st->codec->extradata_size= 10; + st->codec->extradata= av_mallocz(st->codec->extradata_size); /* 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 */ //FIXME pass the unpermutated extradata - ((uint16_t*)st->codec.extradata)[1]= sub_packet_h; - ((uint16_t*)st->codec.extradata)[2]= flavor; - ((uint16_t*)st->codec.extradata)[3]= coded_framesize; + ((uint16_t*)st->codec->extradata)[1]= sub_packet_h; + ((uint16_t*)st->codec->extradata)[2]= flavor; + ((uint16_t*)st->codec->extradata)[3]= coded_framesize; } else { - st->codec.codec_id = CODEC_ID_NONE; - pstrcpy(st->codec.codec_name, sizeof(st->codec.codec_name), + st->codec->codec_id = CODEC_ID_NONE; + pstrcpy(st->codec->codec_name, sizeof(st->codec->codec_name), buf); } if (read_all) { @@ -635,7 +635,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) goto fail; st->id = get_be16(pb); 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); /* avg packet size */ 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 */ codec_data_size = get_be32(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); v = get_be32(pb); @@ -658,43 +658,43 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) int fps, fps2; if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { 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; } - 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')); - 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', '3', '0') - && st->codec.codec_tag != MKTAG('R', 'V', '4', '0')) + 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')); + 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', '3', '0') + && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) goto fail1; - st->codec.width = get_be16(pb); - st->codec.height = get_be16(pb); - st->codec.time_base.num= 1; + st->codec->width = get_be16(pb); + st->codec->height = get_be16(pb); + st->codec->time_base.num= 1; fps= get_be16(pb); - st->codec.codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_type = CODEC_TYPE_VIDEO; get_be32(pb); fps2= get_be16(pb); get_be16(pb); - st->codec.extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); - st->codec.extradata= av_malloc(st->codec.extradata_size); - get_buffer(pb, st->codec.extradata, st->codec.extradata_size); + st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); + st->codec->extradata= av_malloc(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); - 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 (!) */ #ifdef WORDS_BIGENDIAN - h263_hack_version = ((uint32_t*)st->codec.extradata)[1]; + h263_hack_version = ((uint32_t*)st->codec->extradata)[1]; #else - h263_hack_version = bswap_32(((uint32_t*)st->codec.extradata)[1]); + h263_hack_version = bswap_32(((uint32_t*)st->codec->extradata)[1]); #endif - st->codec.sub_id = h263_hack_version; + st->codec->sub_id = h263_hack_version; switch((h263_hack_version>>28)){ - case 1: st->codec.codec_id = CODEC_ID_RV10; break; - case 2: st->codec.codec_id = CODEC_ID_RV20; break; - case 3: st->codec.codec_id = CODEC_ID_RV30; break; - case 4: st->codec.codec_id = CODEC_ID_RV40; break; + case 1: st->codec->codec_id = CODEC_ID_RV10; break; + case 2: st->codec->codec_id = CODEC_ID_RV20; break; + case 3: st->codec->codec_id = CODEC_ID_RV30; break; + case 4: st->codec->codec_id = CODEC_ID_RV40; break; default: goto fail1; } } @@ -827,7 +827,7 @@ resync: return AVERROR_IO; 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; h= get_byte(pb); len--; @@ -862,8 +862,8 @@ resync: pkt->stream_index = i; #if 0 - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { - if(st->codec.codec_id == CODEC_ID_RV20){ + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { + if(st->codec->codec_id == CODEC_ID_RV20){ 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); @@ -882,7 +882,7 @@ resync: } /* 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; for(j=0;j<len;j+=2) { tmp = ptr[0]; @@ -937,7 +937,7 @@ static int64_t rm_read_dts(AVFormatContext *s, int stream_index, return AV_NOPTS_VALUE; 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--; if(!(h & 0x40)){ seq = get_byte(&s->pb); len--; diff --git a/libavformat/rtp.c b/libavformat/rtp.c index 63236f00c6..fff10e0043 100644 --- a/libavformat/rtp.c +++ b/libavformat/rtp.c @@ -290,7 +290,7 @@ RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, int payload_t return NULL; } } else { - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: 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) { - AVCodecContext codec; int au_headers_length, au_header_size, i; GetBitContext getbitcontext; rtp_payload_data_t *infos; @@ -317,8 +316,6 @@ static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf) if (infos == NULL) return -1; - codec = s->st->codec; - /* decode the first 2 bytes where are stored the AUHeader sections length in bits */ au_headers_length = BE_16(buf); @@ -407,7 +404,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, return -1; #if defined(DEBUG) || 1 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)); } #endif @@ -428,7 +425,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, return 1; } } else { - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: /* better than nothing: skip mpeg audio RTP header */ if (len <= 4) @@ -462,7 +459,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, break; } - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MPEG1VIDEO: if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { @@ -529,7 +526,7 @@ static int rtp_write_header(AVFormatContext *s1) return -1; st = s1->streams[0]; - payload_type = rtp_get_payload_type(&st->codec); + payload_type = rtp_get_payload_type(st->codec); if (payload_type < 0) payload_type = RTP_PT_PRIVATE; /* private payload type */ s->payload_type = payload_type; @@ -544,7 +541,7 @@ static int rtp_write_header(AVFormatContext *s1) return AVERROR_IO; 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_MP3: s->buf_ptr = s->buf + 4; @@ -663,7 +660,7 @@ static void rtp_send_mpegaudio(AVFormatContext *s1, s->buf_ptr = s->buf + 4; /* 90 KHz time stamp */ 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); 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 @@ -715,7 +712,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, while (size > 0) { /* XXX: more correct headers */ h = 0; - if (st->codec.sub_id == 2) + if (st->codec->sub_id == 2) h |= 1 << 26; /* mpeg 2 indicator */ q = s->buf; *q++ = h >> 24; @@ -723,7 +720,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, *q++ = h >> 8; *q++ = h; - if (st->codec.sub_id == 2) { + if (st->codec->sub_id == 2) { h = 0; *q++ = h >> 24; *q++ = h >> 16; @@ -740,7 +737,7 @@ static void rtp_send_mpegvideo(AVFormatContext *s1, /* 90 KHz time stamp */ 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); buf1 += len; @@ -765,7 +762,7 @@ static void rtp_send_raw(AVFormatContext *s1, /* 90 KHz time stamp */ 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); buf1 += len; @@ -824,18 +821,18 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) s->first_packet = 0; } - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_PCM_MULAW: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_U8: 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; case CODEC_ID_PCM_U16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_S16BE: 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; case CODEC_ID_MP2: case CODEC_ID_MP3: diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 67c23aa4bc..789266e9c0 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -282,7 +282,7 @@ static void sdp_parse_fmtp(AVStream *st, const char *p) int i; 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; /* loop on each attribute */ @@ -405,10 +405,10 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, return; st->priv_data = rtsp_st; 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 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 */ @@ -438,7 +438,7 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, st = s->streams[i]; rtsp_st = st->priv_data; 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)) { diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c index d2954881ed..7727462e21 100644 --- a/libavformat/segafilm.c +++ b/libavformat/segafilm.c @@ -140,11 +140,11 @@ static int film_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; film->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = film->video_type; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = BE_32(&scratch[16]); - st->codec.height = BE_32(&scratch[12]); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = film->video_type; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = BE_32(&scratch[16]); + st->codec->height = BE_32(&scratch[12]); } if (film->audio_type) { @@ -152,16 +152,16 @@ static int film_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; film->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = film->audio_type; - st->codec.codec_tag = 1; - st->codec.channels = film->audio_channels; - st->codec.bits_per_sample = film->audio_bits; - st->codec.sample_rate = film->audio_samplerate; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = st->codec.channels * - st->codec.bits_per_sample / 8; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = film->audio_type; + st->codec->codec_tag = 1; + st->codec->channels = film->audio_channels; + st->codec->bits_per_sample = film->audio_bits; + st->codec->sample_rate = film->audio_samplerate; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = st->codec->channels * + st->codec->bits_per_sample / 8; } /* load the sample table */ diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c index 09b7a7491a..5f6005bca4 100644 --- a/libavformat/sierravmd.c +++ b/libavformat/sierravmd.c @@ -131,14 +131,14 @@ static int vmd_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); vmd->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_VMDVIDEO; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = LE_16(&vmd->vmd_header[12]); - st->codec.height = LE_16(&vmd->vmd_header[14]); - st->codec.extradata_size = VMD_HEADER_SIZE; - st->codec.extradata = av_malloc(VMD_HEADER_SIZE); - memcpy(st->codec.extradata, vmd->vmd_header, VMD_HEADER_SIZE); + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_VMDVIDEO; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = LE_16(&vmd->vmd_header[12]); + st->codec->height = LE_16(&vmd->vmd_header[14]); + st->codec->extradata_size = VMD_HEADER_SIZE; + st->codec->extradata = av_malloc(VMD_HEADER_SIZE); + memcpy(st->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE); /* if sample rate is 0, assume no audio */ vmd->sample_rate = LE_16(&vmd->vmd_header[804]); @@ -148,29 +148,29 @@ static int vmd_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); vmd->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_VMDAUDIO; - st->codec.codec_tag = 0; /* no codec tag */ - st->codec.channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; - st->codec.sample_rate = vmd->sample_rate; - st->codec.block_align = vmd->audio_block_align = + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_VMDAUDIO; + st->codec->codec_tag = 0; /* no codec tag */ + st->codec->channels = (vmd->vmd_header[811] & 0x80) ? 2 : 1; + st->codec->sample_rate = vmd->sample_rate; + st->codec->block_align = vmd->audio_block_align = LE_16(&vmd->vmd_header[806]); - if (st->codec.block_align & 0x8000) { - st->codec.bits_per_sample = 16; - st->codec.block_align = -(st->codec.block_align - 0x10000); + if (st->codec->block_align & 0x8000) { + st->codec->bits_per_sample = 16; + st->codec->block_align = -(st->codec->block_align - 0x10000); } else - st->codec.bits_per_sample = 16; -// st->codec.bits_per_sample = 8; - st->codec.bit_rate = st->codec.sample_rate * - st->codec.bits_per_sample * st->codec.channels; + st->codec->bits_per_sample = 16; +// st->codec->bits_per_sample = 8; + st->codec->bit_rate = st->codec->sample_rate * + st->codec->bits_per_sample * st->codec->channels; /* for calculating pts */ - vmd->audio_frame_divisor = st->codec.bits_per_sample / 8 / - st->codec.channels; + vmd->audio_frame_divisor = st->codec->bits_per_sample / 8 / + st->codec->channels; video_pts_inc = 90000; - video_pts_inc *= st->codec.block_align; - video_pts_inc /= st->codec.sample_rate; + video_pts_inc *= st->codec->block_align; + video_pts_inc /= st->codec->sample_rate; } else { /* if no audio, assume 10 frames/second */ video_pts_inc = 90000 / 10; diff --git a/libavformat/sol.c b/libavformat/sol.c index eed1b38f32..70dab2ac12 100644 --- a/libavformat/sol.c +++ b/libavformat/sol.c @@ -113,11 +113,11 @@ static int sol_read_header(AVFormatContext *s, st = av_new_stream(s, 0); if (!st) return -1; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_tag = id; - st->codec.codec_id = codec; - st->codec.channels = channels; - st->codec.sample_rate = rate; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_tag = id; + st->codec->codec_id = codec; + st->codec->channels = channels; + st->codec->sample_rate = rate; av_set_pts_info(st, 64, 1, rate); return 0; } diff --git a/libavformat/swf.c b/libavformat/swf.c index c8988bf5f7..923a4f9934 100644 --- a/libavformat/swf.c +++ b/libavformat/swf.c @@ -324,7 +324,7 @@ static int swf_write_header(AVFormatContext *s) video_enc = NULL; audio_enc = NULL; 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) audio_enc = enc; else { @@ -652,7 +652,7 @@ static int swf_write_audio(AVFormatContext *s, 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) return swf_write_audio(s, codec, pkt->data, pkt->size); else @@ -668,7 +668,7 @@ static int swf_write_trailer(AVFormatContext *s) video_enc = NULL; 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) video_enc = enc; } @@ -775,8 +775,8 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) if (tag < 0) { if ( ast || vst ) { if ( vst && ast ) { - vst->codec.time_base.den = ast->codec.sample_rate / swf->samples_per_frame; - vst->codec.time_base.num = 1; + vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame; + vst->codec->time_base.num = 1; } break; } @@ -794,11 +794,11 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) vst = av_new_stream(s, 0); av_set_pts_info(vst, 24, 1, 1000); /* 24 bit pts in ms */ - vst->codec.codec_type = CODEC_TYPE_VIDEO; - vst->codec.codec_id = CODEC_ID_FLV1; + vst->codec->codec_type = CODEC_TYPE_VIDEO; + vst->codec->codec_id = CODEC_ID_FLV1; if ( swf->samples_per_frame ) { - vst->codec.time_base.den = 1000. / swf->ms_per_frame; - vst->codec.time_base.num = 1; + vst->codec->time_base.den = 1000. / swf->ms_per_frame; + vst->codec->time_base.num = 1; } } } else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) { @@ -819,26 +819,26 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) return -ENOMEM; if (v & 0x01) - ast->codec.channels = 2; + ast->codec->channels = 2; else - ast->codec.channels = 1; + ast->codec->channels = 1; switch((v>> 2) & 0x03) { case 1: - ast->codec.sample_rate = 11025; + ast->codec->sample_rate = 11025; break; case 2: - ast->codec.sample_rate = 22050; + ast->codec->sample_rate = 22050; break; case 3: - ast->codec.sample_rate = 44100; + ast->codec->sample_rate = 44100; break; default: av_free(ast); return AVERROR_IO; } - ast->codec.codec_type = CODEC_TYPE_AUDIO; - ast->codec.codec_id = CODEC_ID_MP3; + ast->codec->codec_type = CODEC_TYPE_AUDIO; + ast->codec->codec_id = CODEC_ID_MP3; } } else { url_fskip(pb, len); diff --git a/libavformat/utils.c b/libavformat/utils.c index 37392445ee..efa5bcf770 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -683,14 +683,14 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, *pnum = 0; *pden = 0; - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_VIDEO: if(st->time_base.num*1000LL > st->time_base.den){ *pnum = st->time_base.num; *pden = st->time_base.den; - }else if(st->codec.time_base.num*1000LL > st->codec.time_base.den){ - *pnum = st->codec.time_base.num; - *pden = st->codec.time_base.den; + }else if(st->codec->time_base.num*1000LL > st->codec->time_base.den){ + *pnum = st->codec->time_base.num; + *pden = st->codec->time_base.den; if (pc && pc->repeat_pict) { *pden *= 2; *pnum = (*pnum) * (2 + pc->repeat_pict); @@ -698,11 +698,11 @@ static void compute_frame_duration(int *pnum, int *pden, AVStream *st, } break; 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) break; *pnum = frame_size; - *pden = st->codec.sample_rate; + *pden = st->codec->sample_rate; break; default: 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; /* do we have a video B frame ? */ 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 not initialized */ - if (( st->codec.codec_id == CODEC_ID_H264 - || st->codec.has_b_frames) && + if (( st->codec->codec_id == CODEC_ID_H264 + || st->codec->has_b_frames) && pc && pc->pict_type != FF_B_TYPE) presentation_delayed = 1; /* this may be redundant, but it shouldnt hurt */ @@ -834,7 +834,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, if (pc) { pkt->flags = 0; /* key frame computation */ - switch(st->codec.codec_type) { + switch(st->codec->codec_type) { case CODEC_TYPE_VIDEO: if (pc->pict_type == FF_I_TYPE) pkt->flags |= PKT_FLAG_KEY; @@ -870,7 +870,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt) s->cur_st = NULL; return 0; } 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_pkt.pts, s->cur_pkt.dts); 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++) { st = s->streams[i]; if (st->parser && st->need_parsing) { - av_parser_parse(st->parser, &st->codec, + av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size, NULL, 0, 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_len = s->cur_pkt.size; 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) { /* no parser available : just output the raw packets */ st->need_parsing = 0; @@ -995,7 +995,7 @@ int av_find_default_stream_index(AVFormatContext *s) return -1; for(i = 0; i < s->nb_streams; i++) { st = s->streams[i]; - if (st->codec.codec_type == CODEC_TYPE_VIDEO) { + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { return i; } } @@ -1537,7 +1537,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) bit_rate = 0; for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - bit_rate += st->codec.bit_rate; + bit_rate += st->codec->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; AVFrame picture; - if(!st->codec.codec){ - codec = avcodec_find_decoder(st->codec.codec_id); + if(!st->codec->codec){ + codec = avcodec_find_decoder(st->codec->codec_id); if (!codec) return -1; - ret = avcodec_open(&st->codec, codec); + ret = avcodec_open(st->codec, codec); if (ret < 0) return ret; } - if(!has_codec_parameters(&st->codec)){ - switch(st->codec.codec_type) { + if(!has_codec_parameters(st->codec)){ + switch(st->codec->codec_type) { case CODEC_TYPE_VIDEO: - ret = avcodec_decode_video(&st->codec, &picture, + ret = avcodec_decode_video(st->codec, &picture, &got_picture, (uint8_t *)data, size); break; case CODEC_TYPE_AUDIO: samples = av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); if (!samples) goto fail; - ret = avcodec_decode_audio(&st->codec, samples, + ret = avcodec_decode_audio(st->codec, samples, &got_picture, (uint8_t *)data, size); av_free(samples); break; @@ -1787,15 +1787,15 @@ int av_find_stream_info(AVFormatContext *ic) for(i=0;i<ic->nb_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) st->time_base= */ - if(!st->codec.time_base.num) - st->codec.time_base= st->time_base; + if(!st->codec->time_base.num) + st->codec->time_base= st->time_base; } //only for the split stuff 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 */ for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - if (!has_codec_parameters(&st->codec)) + if (!has_codec_parameters(st->codec)) break; /* variable fps and no guess at the real fps */ - if( st->codec.time_base.den >= 1000LL*st->codec.time_base.num - && duration_count[i]<20 && st->codec.codec_type == CODEC_TYPE_VIDEO) + if( st->codec->time_base.den >= 1000LL*st->codec->time_base.num + && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO) break; - if(st->parser && st->parser->parser->split && !st->codec.extradata) + if(st->parser && st->parser->parser->split && !st->codec->extradata) break; } 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 */ for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - if (!has_codec_parameters(&st->codec)) + if (!has_codec_parameters(st->codec)) break; } if (i == ic->nb_streams) @@ -1898,12 +1898,12 @@ int av_find_stream_info(AVFormatContext *ic) } last_dts[pkt->stream_index]= pkt->dts; } - if(st->parser && st->parser->parser->split && !st->codec.extradata){ - int i= st->parser->parser->split(&st->codec, pkt->data, pkt->size); + if(st->parser && st->parser->parser->split && !st->codec->extradata){ + int i= st->parser->parser->split(st->codec, pkt->data, pkt->size); if(i){ - st->codec.extradata_size= i; - st->codec.extradata= av_malloc(st->codec.extradata_size); - memcpy(st->codec.extradata, pkt->data, st->codec.extradata_size); + st->codec->extradata_size= i; + st->codec->extradata= av_malloc(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 it takes longer and uses more memory. For MPEG4, we need to decompress for Quicktime. */ - if (!has_codec_parameters(&st->codec) /*&& - (st->codec.codec_id == CODEC_ID_FLV1 || - st->codec.codec_id == CODEC_ID_H264 || - st->codec.codec_id == CODEC_ID_H263 || - st->codec.codec_id == CODEC_ID_H261 || - st->codec.codec_id == CODEC_ID_VORBIS || - st->codec.codec_id == CODEC_ID_MJPEG || - st->codec.codec_id == CODEC_ID_PNG || - st->codec.codec_id == CODEC_ID_PAM || - st->codec.codec_id == CODEC_ID_PGM || - st->codec.codec_id == CODEC_ID_PGMYUV || - st->codec.codec_id == CODEC_ID_PBM || - st->codec.codec_id == CODEC_ID_PPM || - st->codec.codec_id == CODEC_ID_SHORTEN || - (st->codec.codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/) + if (!has_codec_parameters(st->codec) /*&& + (st->codec->codec_id == CODEC_ID_FLV1 || + st->codec->codec_id == CODEC_ID_H264 || + st->codec->codec_id == CODEC_ID_H263 || + st->codec->codec_id == CODEC_ID_H261 || + st->codec->codec_id == CODEC_ID_VORBIS || + st->codec->codec_id == CODEC_ID_MJPEG || + st->codec->codec_id == CODEC_ID_PNG || + st->codec->codec_id == CODEC_ID_PAM || + st->codec->codec_id == CODEC_ID_PGM || + st->codec->codec_id == CODEC_ID_PGMYUV || + st->codec->codec_id == CODEC_ID_PBM || + st->codec->codec_id == CODEC_ID_PPM || + st->codec->codec_id == CODEC_ID_SHORTEN || + (st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/) 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) { @@ -1937,16 +1937,16 @@ int av_find_stream_info(AVFormatContext *ic) // close codecs which where opened in try_decode_frame() for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - if(st->codec.codec) - avcodec_close(&st->codec); + if(st->codec->codec) + avcodec_close(st->codec); } for(i=0;i<ic->nb_streams;i++) { st = ic->streams[i]; - 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) - st->codec.codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec.pix_fmt); + 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) + 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){ AVRational fps1; int64_t num, den; @@ -1964,14 +1964,14 @@ int av_find_stream_info(AVFormatContext *ic) /* set real frame rate info */ /* compute the real frame rate for telecine */ - if ((st->codec.codec_id == CODEC_ID_MPEG1VIDEO || - st->codec.codec_id == CODEC_ID_MPEG2VIDEO) && - st->codec.sub_id == 2) { + if ((st->codec->codec_id == CODEC_ID_MPEG1VIDEO || + st->codec->codec_id == CODEC_ID_MPEG2VIDEO) && + st->codec->sub_id == 2) { if (st->codec_info_nb_frames >= 20) { float coded_frame_rate, est_frame_rate; est_frame_rate = ((double)st->codec_info_nb_frames * AV_TIME_BASE) / (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 printf("telecine: coded_frame_rate=%0.3f est_frame_rate=%0.3f\n", 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 (!st->r_frame_rate.num){ - st->r_frame_rate.num = st->codec.time_base.den; - st->r_frame_rate.den = st->codec.time_base.num; + st->r_frame_rate.num = st->codec->time_base.den; + 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 */ for(i=0;i<ic->nb_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){ ppktl = &ic->packet_buffer; while(ppkt1){ @@ -2069,6 +2069,7 @@ void av_close_input_file(AVFormatContext *s) av_parser_close(st->parser); } av_free(st->index_entries); + av_free(st->codec); av_free(st); } flush_packet_queue(s); @@ -2103,10 +2104,11 @@ AVStream *av_new_stream(AVFormatContext *s, int id) st = av_mallocz(sizeof(AVStream)); if (!st) return NULL; - avcodec_get_context_defaults(&st->codec); + + st->codec= avcodec_alloc_context(); if (s->iformat) { /* no default bitrate if decoding */ - st->codec.bit_rate = 0; + st->codec->bit_rate = 0; } st->index = s->nb_streams; st->id = id; @@ -2164,14 +2166,14 @@ int av_write_header(AVFormatContext *s) for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; - switch (st->codec.codec_type) { + switch (st->codec->codec_type) { case CODEC_TYPE_AUDIO: 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; case CODEC_TYPE_VIDEO: 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; default: break; @@ -2182,7 +2184,7 @@ int av_write_header(AVFormatContext *s) //FIXME merge with compute_pkt_fields 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; // 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; /* update pts */ - switch (st->codec.codec_type) { + switch (st->codec->codec_type) { 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, 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; 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; default: break; @@ -2380,7 +2382,7 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt){ AVStream *st= s->streams[ pkt->stream_index]; //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; //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++) { 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); /* the pid is an important information, so we display it */ /* XXX: add a generic system */ diff --git a/libavformat/wav.c b/libavformat/wav.c index 427453b3a8..6557c0a962 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -199,13 +199,13 @@ static int wav_write_header(AVFormatContext *s) /* format header */ 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); return -1; } 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 */ wav->data = start_tag(pb, "data"); @@ -305,10 +305,10 @@ static int wav_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; - get_wav_header(pb, &st->codec, size); + get_wav_header(pb, st->codec, size); 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')); if (size < 0) @@ -329,10 +329,10 @@ static int wav_read_packet(AVFormatContext *s, st = s->streams[0]; size = MAX_SIZE; - if (st->codec.block_align > 1) { - if (size < st->codec.block_align) - size = st->codec.block_align; - size = (size / st->codec.block_align) * st->codec.block_align; + if (st->codec->block_align > 1) { + if (size < st->codec->block_align) + size = st->codec->block_align; + size = (size / st->codec->block_align) * st->codec->block_align; } if (av_new_packet(pkt, size)) return AVERROR_IO; @@ -358,7 +358,7 @@ static int wav_read_seek(AVFormatContext *s, AVStream *st; st = s->streams[0]; - switch(st->codec.codec_id) { + switch(st->codec->codec_id) { case CODEC_ID_MP2: case CODEC_ID_MP3: case CODEC_ID_AC3: diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c index 30417fef15..23c13324b4 100644 --- a/libavformat/wc3movie.c +++ b/libavformat/wc3movie.c @@ -239,29 +239,29 @@ static int wc3_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); wc3->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_XAN_WC3; - st->codec.codec_tag = 0; /* no fourcc */ - st->codec.width = wc3->width; - st->codec.height = wc3->height; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_XAN_WC3; + st->codec->codec_tag = 0; /* no fourcc */ + st->codec->width = wc3->width; + st->codec->height = wc3->height; /* palette considerations */ - st->codec.palctrl = &wc3->palette_control; + st->codec->palctrl = &wc3->palette_control; st = av_new_stream(s, 0); if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); wc3->audio_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_PCM_S16LE; - st->codec.codec_tag = 1; - st->codec.channels = WC3_AUDIO_CHANNELS; - st->codec.bits_per_sample = WC3_AUDIO_BITS; - st->codec.sample_rate = WC3_SAMPLE_RATE; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample; - st->codec.block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_PCM_S16LE; + st->codec->codec_tag = 1; + st->codec->channels = WC3_AUDIO_CHANNELS; + st->codec->bits_per_sample = WC3_AUDIO_BITS; + st->codec->sample_rate = WC3_SAMPLE_RATE; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample; + st->codec->block_align = WC3_AUDIO_BITS * WC3_AUDIO_CHANNELS; return 0; } diff --git a/libavformat/westwood.c b/libavformat/westwood.c index 22150e2a64..1d3e325e4f 100644 --- a/libavformat/westwood.c +++ b/libavformat/westwood.c @@ -136,15 +136,15 @@ static int wsaud_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, wsaud->audio_samplerate); - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = wsaud->audio_type; - st->codec.codec_tag = 0; /* no tag */ - st->codec.channels = wsaud->audio_channels; - st->codec.sample_rate = wsaud->audio_samplerate; - st->codec.bits_per_sample = wsaud->audio_bits; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample / 4; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = wsaud->audio_type; + st->codec->codec_tag = 0; /* no tag */ + st->codec->channels = wsaud->audio_channels; + st->codec->sample_rate = wsaud->audio_samplerate; + st->codec->bits_per_sample = wsaud->audio_bits; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; wsaud->audio_stream_index = st->index; wsaud->audio_frame_counter = 0; @@ -222,24 +222,24 @@ static int wsvqa_read_header(AVFormatContext *s, return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); wsvqa->video_stream_index = st->index; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_WS_VQA; - st->codec.codec_tag = 0; /* no fourcc */ + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_WS_VQA; + st->codec->codec_tag = 0; /* no fourcc */ /* skip to the start of the VQA header */ url_fseek(pb, 20, SEEK_SET); /* the VQA header needs to go to the decoder */ - st->codec.extradata_size = VQA_HEADER_SIZE; - st->codec.extradata = av_malloc(VQA_HEADER_SIZE); - header = (unsigned char *)st->codec.extradata; - if (get_buffer(pb, st->codec.extradata, VQA_HEADER_SIZE) != + st->codec->extradata_size = VQA_HEADER_SIZE; + st->codec->extradata = av_malloc(VQA_HEADER_SIZE); + header = (unsigned char *)st->codec->extradata; + if (get_buffer(pb, st->codec->extradata, VQA_HEADER_SIZE) != VQA_HEADER_SIZE) { - av_free(st->codec.extradata); + av_free(st->codec->extradata); return AVERROR_IO; } - st->codec.width = LE_16(&header[6]); - st->codec.height = LE_16(&header[8]); + st->codec->width = LE_16(&header[6]); + st->codec->height = LE_16(&header[8]); /* initialize the audio decoder stream is sample rate is non-zero */ if (LE_16(&header[24])) { @@ -247,19 +247,19 @@ static int wsvqa_read_header(AVFormatContext *s, if (!st) return AVERROR_NOMEM; av_set_pts_info(st, 33, 1, 90000); - st->codec.codec_type = CODEC_TYPE_AUDIO; - st->codec.codec_id = CODEC_ID_ADPCM_IMA_WS; - st->codec.codec_tag = 0; /* no tag */ - st->codec.sample_rate = LE_16(&header[24]); - st->codec.channels = header[26]; - st->codec.bits_per_sample = 16; - st->codec.bit_rate = st->codec.channels * st->codec.sample_rate * - st->codec.bits_per_sample / 4; - st->codec.block_align = st->codec.channels * st->codec.bits_per_sample; + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_ADPCM_IMA_WS; + st->codec->codec_tag = 0; /* no tag */ + st->codec->sample_rate = LE_16(&header[24]); + st->codec->channels = header[26]; + st->codec->bits_per_sample = 16; + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * + st->codec->bits_per_sample / 4; + st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; wsvqa->audio_stream_index = st->index; - wsvqa->audio_samplerate = st->codec.sample_rate; - wsvqa->audio_channels = st->codec.channels; + wsvqa->audio_samplerate = st->codec->sample_rate; + wsvqa->audio_channels = st->codec->channels; 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 */ do { if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) { - av_free(st->codec.extradata); + av_free(st->codec->extradata); return AVERROR_IO; } chunk_tag = BE_32(&scratch[0]); diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c index 74519fa1b6..1f38fe8689 100644 --- a/libavformat/yuv4mpeg.c +++ b/libavformat/yuv4mpeg.c @@ -33,22 +33,22 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) char *colorspace = ""; st = s->streams[0]; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + 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; - aspectd = st->codec.sample_aspect_ratio.den; + aspectn = st->codec->sample_aspect_ratio.num; + aspectd = st->codec->sample_aspect_ratio.den; if ( aspectn == 0 && aspectd == 1 ) aspectd = 0; // 0:0 means unknown inter = 'p'; /* progressive is the default */ - if (st->codec.coded_frame && st->codec.coded_frame->interlaced_frame) { - inter = st->codec.coded_frame->top_field_first ? 't' : 'b'; + if (st->codec->coded_frame && st->codec->coded_frame->interlaced_frame) { + inter = st->codec->coded_frame->top_field_first ? 't' : 'b'; } - switch(st->codec.pix_fmt) { + switch(st->codec->pix_fmt) { case PIX_FMT_GRAY8: colorspace = " Cmono"; break; @@ -56,7 +56,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf) colorspace = " C411 XYSCSS=411"; break; 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; case PIX_FMT_YUV422P: 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); put_buffer(pb, buf1, strlen(buf1)); - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + height = st->codec->height; ptr = picture->data[0]; for(i=0;i<height;i++) { @@ -118,9 +118,9 @@ static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) 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 - 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; height >>= v_chroma_shift; @@ -146,13 +146,13 @@ static int yuv4_write_header(AVFormatContext *s) if (s->nb_streams != 1) 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"); } - 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_GRAY8) && - (s->streams[0]->codec.pix_fmt != PIX_FMT_YUV444P)) { + 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_GRAY8) && + (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"); return AVERROR_IO; } @@ -320,14 +320,14 @@ static int yuv4_read_header(AVFormatContext *s, AVFormatParameters *ap) st = av_new_stream(s, 0); st = s->streams[0]; - st->codec.width = width; - st->codec.height = height; + st->codec->width = width; + st->codec->height = height; av_reduce(&raten, &rated, raten, rated, (1UL<<31)-1); av_set_pts_info(st, 64, rated, raten); - st->codec.pix_fmt = pix_fmt; - st->codec.codec_type = CODEC_TYPE_VIDEO; - st->codec.codec_id = CODEC_ID_RAWVIDEO; - st->codec.sample_aspect_ratio= (AVRational){aspectn, aspectd}; + st->codec->pix_fmt = pix_fmt; + st->codec->codec_type = CODEC_TYPE_VIDEO; + st->codec->codec_id = CODEC_ID_RAWVIDEO; + st->codec->sample_aspect_ratio= (AVRational){aspectn, aspectd}; return 0; } @@ -349,10 +349,10 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt) if (i == MAX_FRAME_HEADER) return -1; if (strncmp(header, Y4M_FRAME_MAGIC, strlen(Y4M_FRAME_MAGIC))) return -1; - width = st->codec.width; - height = st->codec.height; + width = st->codec->width; + 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) return -1; diff --git a/output_example.c b/output_example.c index bf657275fe..e419c24f4a 100644 --- a/output_example.c +++ b/output_example.c @@ -62,7 +62,7 @@ AVStream *add_audio_stream(AVFormatContext *oc, int codec_id) exit(1); } - c = &st->codec; + c = st->codec; c->codec_id = codec_id; c->codec_type = CODEC_TYPE_AUDIO; @@ -78,7 +78,7 @@ void open_audio(AVFormatContext *oc, AVStream *st) AVCodecContext *c; AVCodec *codec; - c = &st->codec; + c = st->codec; /* find the audio encoder */ 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 */ if (c->frame_size <= 1) { 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_S16BE: case CODEC_ID_PCM_U16LE: @@ -145,7 +145,7 @@ void write_audio_frame(AVFormatContext *oc, AVStream *st) AVPacket pkt; av_init_packet(&pkt); - c = &st->codec; + c = st->codec; 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) { - avcodec_close(&st->codec); + avcodec_close(st->codec); av_free(samples); av_free(audio_outbuf); @@ -190,7 +190,7 @@ AVStream *add_video_stream(AVFormatContext *oc, int codec_id) exit(1); } - c = &st->codec; + c = st->codec; c->codec_id = codec_id; c->codec_type = CODEC_TYPE_VIDEO; @@ -246,7 +246,7 @@ void open_video(AVFormatContext *oc, AVStream *st) AVCodec *codec; AVCodecContext *c; - c = &st->codec; + c = st->codec; /* find the video encoder */ codec = avcodec_find_encoder(c->codec_id); @@ -317,7 +317,7 @@ void write_video_frame(AVFormatContext *oc, AVStream *st) int out_size, ret; AVCodecContext *c; - c = &st->codec; + c = st->codec; if (frame_count >= STREAM_NB_FRAMES) { /* 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) { - avcodec_close(&st->codec); + avcodec_close(st->codec); av_free(picture->data[0]); av_free(picture); if (tmp_picture) { |