• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/libav-0.8.8/

Lines Matching defs:ost

335 static int configure_video_filters(InputStream *ist, OutputStream *ost)
339 AVCodecContext *codec = ost->st->codec;
346 ost->graph = avfilter_graph_alloc();
357 ret = avfilter_graph_create_filter(&ost->input_video_filter, avfilter_get_by_name("buffer"),
358 "src", args, NULL, ost->graph);
361 ret = avfilter_graph_create_filter(&ost->output_video_filter, &avsink,
362 "out", NULL, &avsink_ctx, ost->graph);
365 last_filter = ost->input_video_filter;
371 ost->sws_flags);
373 NULL, args, NULL, ost->graph)) < 0)
380 snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags);
381 ost->graph->scale_sws_opts = av_strdup(args);
383 if (ost->avfilter) {
393 inputs->filter_ctx = ost->output_video_filter;
397 if ((ret = avfilter_graph_parse(ost->graph, ost->avfilter, inputs, outputs, NULL)) < 0)
399 av_freep(&ost->avfilter);
401 if ((ret = avfilter_link(last_filter, 0, ost->output_video_filter, 0)) < 0)
405 if ((ret = avfilter_graph_config(ost->graph, NULL)) < 0)
408 codec->width = ost->output_video_filter->inputs[0]->w;
409 codec->height = ost->output_video_filter->inputs[0]->h;
410 codec->sample_aspect_ratio = ost->st->sample_aspect_ratio =
411 ost->frame_aspect_ratio ? // overriden by the -aspect cli option
412 av_d2q(ost->frame_aspect_ratio*codec->height/codec->width, 255) :
413 ost->output_video_filter->inputs[0]->sample_aspect_ratio;
642 OutputStream *ost;
656 ost = output_streams_for_file[file_idx][idx] =
658 if (!ost) {
662 ost->file_index = file_idx;
663 ost->index = idx;
664 ost->st = st;
665 ost->enc = codec;
667 ost->opts = filter_codec_opts(codec_opts, codec->id, oc, st);
671 ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
672 return ost;
686 OutputStream *ost;
690 ost = new_output_stream(s, nb_output_files, codec);
691 st = ost->st;
716 get_sync_ipts(const OutputStream *ost)
718 const InputStream *ist = ost->sync_ist;
757 OutputStream *ost,
766 AVCodecContext *enc= ost->st->codec;
797 ost->audio_resample = 1;
799 resample_changed = ost->resample_sample_fmt != dec->sample_fmt ||
800 ost->resample_channels != dec->channels ||
801 ost->resample_sample_rate != dec->sample_rate;
803 if ((ost->audio_resample && !ost->resample) || resample_changed) {
807 ost->resample_sample_rate, av_get_sample_fmt_name(ost->resample_sample_fmt), ost->resample_channels,
809 ost->resample_sample_fmt = dec->sample_fmt;
810 ost->resample_channels = dec->channels;
811 ost->resample_sample_rate = dec->sample_rate;
812 if (ost->resample)
813 audio_resample_close(ost->resample);
817 ost->resample_sample_fmt == enc->sample_fmt &&
818 ost->resample_channels == enc->channels &&
819 ost->resample_sample_rate == enc->sample_rate) {
820 ost->resample = NULL;
821 ost->audio_resample = 0;
822 } else if (ost->audio_resample) {
825 ost->resample = av_audio_resample_init(enc->channels, dec->channels,
829 if (!ost->resample) {
839 if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt &&
840 MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=ost->reformat_pair) {
841 if (ost->reformat_ctx)
842 av_audio_convert_free(ost->reformat_ctx);
843 ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1,
845 if (!ost->reformat_ctx) {
851 ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt);
855 double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
856 - av_fifo_size(ost->fifo)/(enc->channels * 2);
891 av_assert0(ost->audio_resample);
894 // fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2));
895 av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate);
899 ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate)
900 - av_fifo_size(ost->fifo)/(enc->channels * 2); //FIXME wrong
902 if (ost->audio_resample) {
904 size_out = audio_resample(ost->resample,
913 if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt) {
919 if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) {
932 if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
936 av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL);
940 while (av_fifo_size(ost->fifo) >= frame_bytes) {
944 av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
946 //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
955 pkt.stream_index= ost->index;
959 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
961 write_frame(s, &pkt, enc, ost->bitstream_filters);
963 ost->sync_opts += enc->frame_size;
969 ost->sync_opts += size_out / (osize * enc->channels);
982 //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
990 pkt.stream_index= ost->index;
994 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
996 write_frame(s, &pkt, enc, ost->bitstream_filters);
1043 OutputStream *ost,
1061 enc = ost->st->codec;
1089 pkt.stream_index = ost->index;
1092 pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
1101 write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
1109 OutputStream *ost,
1119 enc = ost->st->codec;
1122 sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
1130 double vdelta = sync_ipts - ost->sync_opts;
1138 ost->sync_opts= lrintf(sync_ipts);
1141 //fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames);
1152 ost->sync_opts= lrintf(sync_ipts);
1154 nb_frames= FFMIN(nb_frames, max_frames[AVMEDIA_TYPE_VIDEO] - ost->frame_number);
1161 resample_changed = ost->resample_width != dec->width ||
1162 ost->resample_height != dec->height ||
1163 ost->resample_pix_fmt != dec->pix_fmt;
1169 ost->resample_width, ost->resample_height, av_get_pix_fmt_name(ost->resample_pix_fmt),
1171 if(!ost->video_resample)
1176 if (ost->video_resample) {
1177 final_picture = &ost->pict_tmp;
1180 sws_freeContext(ost->img_resample_ctx);
1181 ost->img_resample_ctx = sws_getContext(
1185 ost->st->codec->width,
1186 ost->st->codec->height,
1187 ost->st->codec->pix_fmt,
1188 ost->sws_flags, NULL, NULL, NULL);
1189 if (ost->img_resample_ctx == NULL) {
1194 sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
1195 0, ost->resample_height, final_picture->data, final_picture->linesize);
1203 pkt.stream_index= ost->index;
1213 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
1216 write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
1225 if (ost->st->codec->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)) {
1238 big_picture.pts= ost->sync_opts;
1239 // big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->time_base.num, enc->time_base.den);
1240 //av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
1241 if (ost->forced_kf_index < ost->forced_kf_count &&
1242 big_picture.pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
1244 ost->forced_kf_index++;
1258 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
1265 write_frame(s, &pkt, ost->st->codec, ost->bitstream_filters);
1271 if (ost->logfile && enc->stats_out) {
1272 fprintf(ost->logfile, "%s", enc->stats_out);
1276 ost->sync_opts++;
1277 ost->frame_number++;
1285 static void do_video_stats(AVFormatContext *os, OutputStream *ost,
1301 enc = ost->st->codec;
1303 frame_number = ost->frame_number;
1310 ti1 = ost->sync_opts * av_q2d(enc->time_base);
1327 OutputStream *ost;
1361 ost = ost_table[i];
1362 enc = ost->st->codec;
1363 if (!ost->st->stream_copy && enc->coded_frame)
1371 frame_number = ost->frame_number;
1408 pts = (double)ost->st->pts.val * av_q2d(ost->st->time_base);
1458 OutputStream *ost;
1604 ost = ost_table[i];
1605 if (ost->input_video_filter && ost->source_index == ist_index) {
1612 av_vsrc_buffer_add_frame(ost->input_video_filter, &picture,
1647 ost = ost_table[i];
1648 if (ost->source_index == ist_index) {
1651 !ost->output_video_filter || avfilter_poll_frame(ost->output_video_filter->inputs[0]);
1654 if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter)
1655 get_filtered_video_frame(ost->output_video_filter, &picture, &ost->picref, &ist_pts_tb);
1656 if (ost->picref)
1657 ist->pts = av_rescale_q(ost->picref->pts, ist_pts_tb, AV_TIME_BASE_Q);
1659 os = output_files[ost->file_index];
1662 //ost->sync_ipts = (double)(ist->pts + input_files[ist->file_index].ts_offset - start_time)/ AV_TIME_BASE;
1664 if (ost->encoding_needed) {
1666 switch(ost->st->codec->codec_type) {
1668 do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
1672 if (ost->picref->video && !ost->frame_aspect_ratio)
1673 ost->st->codec->sample_aspect_ratio = ost->picref->video->pixel_aspect;
1675 do_video_out(os, ost, ist, &picture, &frame_size,
1676 same_quality ? quality : ost->st->codec->global_quality);
1678 do_video_stats(os, ost, frame_size);
1681 do_subtitle_out(os, ost, ist, &subtitle,
1690 int64_t ost_tb_start_time= av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base);
1694 if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
1705 ost->st->codec->coded_frame= &avframe;
1708 if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
1710 else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
1712 ost->sync_opts++;
1715 opkt.stream_index= ost->index;
1717 opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;
1722 opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base);
1724 opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);
1727 opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
1731 if( ost->st->codec->codec_id != CODEC_ID_H264
1732 && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
1733 && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
1735 if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
1742 write_frame(os, &opkt, ost->st->codec, ost->bitstream_filters);
1743 ost->st->codec->frame_number++;
1744 ost->frame_number++;
1750 ost->output_video_filter && avfilter_poll_frame(ost->output_video_filter->inputs[0]);
1751 if (ost->picref)
1752 avfilter_unref_buffer(ost->picref);
1770 ost = ost_table[i];
1771 if (ost->source_index == ist_index) {
1772 AVCodecContext *enc= ost->st->codec;
1773 os = output_files[ost->file_index];
1775 if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
1777 if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
1780 if (ost->encoding_needed) {
1785 pkt.stream_index= ost->index;
1787 switch(ost->st->codec->codec_type) {
1789 fifo_bytes = av_fifo_size(ost->fifo);
1796 av_fifo_generic_read(ost->fifo, audio_buf, fifo_bytes, NULL);
1807 pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den,
1808 ost->st->time_base.num, enc->sample_rate);
1830 if (ost->logfile && enc->stats_out) {
1831 fprintf(ost->logfile, "%s", enc->stats_out);
1843 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
1844 write_frame(os, &pkt, ost->st->codec, ost->bitstream_filters);
1903 static void parse_forced_key_frames(char *kf, OutputStream *ost,
1913 ost->forced_kf_count = n;
1914 ost->forced_kf_pts = av_malloc(sizeof(*ost->forced_kf_pts) * n);
1915 if (!ost->forced_kf_pts) {
1922 ost->forced_kf_pts[i] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base);
1938 OutputStream *ost, **ost_table = NULL;
1996 ost = ost_table[n] = output_streams_for_file[k][i];
1998 ost->source_index = input_files[stream_maps[n].file_index].ist_index +
2002 if (input_streams[ost->source_index].st->codec->codec_type != ost->st->codec->codec_type) {
2003 int i= ost->file_index;
2007 ost->file_index, ost->index);
2032 ist->st->codec->codec_type == ost->st->codec->codec_type) {
2035 ost->source_index = j;
2046 if ( ist->st->codec->codec_type == ost->st->codec->codec_type
2048 ost->source_index = j;
2054 int i= ost->file_index;
2057 ost->file_index, ost->index);
2062 ist = &input_streams[ost->source_index];
2064 ost->sync_ist = (nb_stream_maps > 0) ?
2072 ost = ost_table[i];
2073 os = output_files[ost->file_index];
2074 ist = &input_streams[ost->source_index];
2076 codec = ost->st->codec;
2080 av_dict_copy(&ost->st->metadata, ist->st->metadata,
2083 ost->st->disposition = ist->st->disposition;
2087 if (ost->st->stream_copy) {
2143 ost->st->sample_aspect_ratio =
2159 if (!ost->enc)
2160 ost->enc = avcodec_find_encoder(ost->st->codec->codec_id);
2163 ost->fifo= av_fifo_alloc(1024);
2164 if(!ost->fifo)
2166 ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE);
2172 choose_sample_rate(ost->st, ost->enc);
2176 choose_sample_fmt(ost->st, ost->enc);
2182 ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
2185 ost->encoding_needed = 1;
2186 ost->resample_sample_fmt = icodec->sample_fmt;
2187 ost->resample_sample_rate = icodec->sample_rate;
2188 ost->resample_channels = icodec->channels;
2193 choose_pixel_fmt(ost->st, ost->enc);
2195 if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
2205 ost->video_resample = codec->width != icodec->width ||
2208 if (ost->video_resample) {
2210 avcodec_get_frame_defaults(&ost->pict_tmp);
2211 if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
2216 ost->img_resample_ctx = sws_getContext(
2223 ost->sws_flags, NULL, NULL, NULL);
2224 if (ost->img_resample_ctx == NULL) {
2232 ost->resample_height = icodec->height;
2233 ost->resample_width = icodec->width;
2234 ost->resample_pix_fmt= icodec->pix_fmt;
2235 ost->encoding_needed = 1;
2238 if (!ost->frame_rate.num)
2239 ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1};
2240 if (ost->enc && ost->enc->supported_framerates && !force_fps) {
2241 int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
2242 ost->frame_rate = ost->enc->supported_framerates[idx];
2244 codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num};
2247 if (configure_video_filters(ist, ost)) {
2254 ost->encoding_needed = 1;
2262 if (ost->encoding_needed &&
2276 ost->logfile = f;
2305 ost = ost_table[i];
2306 if (ost->encoding_needed) {
2307 AVCodec *codec = ost->enc;
2308 AVCodecContext *dec = input_streams[ost->source_index].st->codec;
2311 ost->st->codec->codec_id, ost->file_index, ost->index);
2316 ost->st->codec->subtitle_header = av_malloc(dec->subtitle_header_size);
2317 if (!ost->st->codec->subtitle_header) {
2321 memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
2322 ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
2324 if (avcodec_open2(ost->st->codec, codec, &ost->opts) < 0) {
2326 ost->file_index, ost->index);
2330 assert_codec_experimental(ost->st->codec, 1);
2331 assert_avoptions(ost->opts);
2332 if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
2335 extra_size += ost->st->codec->extradata_size;
2356 ost = ost_table[j];
2357 if (ost->source_index == i) {
2358 update_sample_fmt(ist->st->codec, codec, ost->st->codec);
2370 assert_avoptions(ost->opts);
2499 ost = ost_table[i];
2501 input_streams[ost->source_index].file_index,
2502 input_streams[ost->source_index].st->index,
2503 ost->file_index,
2504 ost->index);
2505 if (ost->sync_ist != &input_streams[ost->source_index])
2507 ost->sync_ist->file_index,
2508 ost->sync_ist->st->index);
2543 ost = ost_table[i];
2544 os = output_files[ost->file_index];
2545 ist = &input_streams[ost->source_index];
2548 opts = ost->st->pts.val * av_q2d(ost->st->time_base);
2560 if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
2687 ost = ost_table[i];
2688 if (ost->encoding_needed) {
2689 av_freep(&ost->st->codec->stats_in);
2690 avcodec_close(ost->st->codec);
2693 avfilter_graph_free(&ost->graph);
2713 ost = ost_table[i];
2714 if (ost) {
2715 if (ost->st->stream_copy)
2716 av_freep(&ost->st->codec->extradata);
2717 if (ost->logfile) {
2718 fclose(ost->logfile);
2719 ost->logfile = NULL;
2721 av_fifo_free(ost->fifo); /* works even if fifo is not
2723 av_freep(&ost->st->codec->subtitle_header);
2724 av_free(ost->pict_tmp.data[0]);
2725 av_free(ost->forced_kf_pts);
2726 if (ost->video_resample)
2727 sws_freeContext(ost->img_resample_ctx);
2728 if (ost->resample)
2729 audio_resample_close(ost->resample);
2730 if (ost->reformat_ctx)
2731 av_audio_convert_free(ost->reformat_ctx);
2732 av_dict_free(&ost->opts);
2733 av_free(ost);
3400 OutputStream *ost;
3415 ost = new_output_stream(oc, file_idx, codec);
3416 st = ost->st;
3418 ost->frame_aspect_ratio = frame_aspect_ratio;
3421 ost->avfilter= vfilters;
3426 ost->bitstream_filters = video_bitstream_filters;
3450 ost->frame_rate = frame_rate;
3513 parse_forced_key_frames(forced_key_frames, ost, video_enc);
3531 OutputStream *ost;
3545 ost = new_output_stream(oc, file_idx, codec);
3546 st = ost->st;
3548 ost->bitstream_filters = audio_bitstream_filters;
3592 OutputStream *ost;
3595 ost = new_output_stream(oc, file_idx, NULL);
3596 st = ost->st;
3623 OutputStream *ost;
3637 ost = new_output_stream(oc, file_idx, codec);
3638 st = ost->st;
3641 ost->bitstream_filters = subtitle_bitstream_filters;