• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src/router/ffmpeg/

Lines Matching defs:ost

581 get_sync_ipts(const AVOutputStream *ost)
583 const AVInputStream *ist = ost->sync_ist;
622 AVOutputStream *ost,
631 AVCodecContext *enc= ost->st->codec;
661 ost->audio_resample = 1;
663 if (ost->audio_resample && !ost->resample) {
666 ost->resample = av_audio_resample_init(enc->channels, dec->channels,
670 if (!ost->resample) {
679 if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt &&
680 MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt)!=ost->reformat_pair) {
681 if (ost->reformat_ctx)
682 av_audio_convert_free(ost->reformat_ctx);
683 ost->reformat_ctx = av_audio_convert_alloc(enc->sample_fmt, 1,
685 if (!ost->reformat_ctx) {
691 ost->reformat_pair=MAKE_SFMT_PAIR(enc->sample_fmt,dec->sample_fmt);
695 double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
696 - av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2);
731 assert(ost->audio_resample);
734 // 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));
735 av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate);
739 ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate)
740 - av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2); //FIXME wrong
742 if (ost->audio_resample) {
744 size_out = audio_resample(ost->resample,
753 if (!ost->audio_resample && dec->sample_fmt!=enc->sample_fmt) {
759 if (av_audio_convert(ost->reformat_ctx, obuf, ostride, ibuf, istride, len)<0) {
772 if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
776 av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL);
780 while (av_fifo_size(ost->fifo) >= frame_bytes) {
784 av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
786 //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
795 pkt.stream_index= ost->index;
799 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
801 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
803 ost->sync_opts += enc->frame_size;
809 ost->sync_opts += size_out / (osize * enc->channels);
822 //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
830 pkt.stream_index= ost->index;
834 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
836 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
883 AVOutputStream *ost,
901 enc = ost->st->codec;
929 pkt.stream_index = ost->index;
932 pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base);
941 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
949 AVOutputStream *ost,
964 enc = ost->st->codec;
967 sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
975 double vdelta = sync_ipts - ost->sync_opts;
983 ost->sync_opts= lrintf(sync_ipts);
986 //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);
997 ost->sync_opts= lrintf(sync_ipts);
999 nb_frames= FFMIN(nb_frames, max_frames[AVMEDIA_TYPE_VIDEO] - ost->frame_number);
1003 if (ost->video_crop) {
1004 if (av_picture_crop((AVPicture *)&picture_crop_temp, (AVPicture *)in_picture, dec->pix_fmt, ost->topBand, ost->leftBand) < 0) {
1017 resampling_dst = &ost->pict_tmp;
1018 if (ost->video_pad) {
1019 final_picture = &ost->pict_tmp;
1020 if (ost->video_resample) {
1021 if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
1031 if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
1032 || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
1033 || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
1036 if(!ost->video_resample)
1040 if (ost->video_resample) {
1042 final_picture = &ost->pict_tmp;
1043 if( (ost->resample_height != (ist->st->codec->height - (ost->topBand + ost->bottomBand)))
1044 || (ost->resample_width != (ist->st->codec->width - (ost->leftBand + ost->rightBand)))
1045 || (ost->resample_pix_fmt!= ist->st->codec->pix_fmt) ) {
1048 topBand = ((int64_t)ist->st->codec->height * ost->original_topBand / ost->original_height) & ~1;
1049 bottomBand = ((int64_t)ist->st->codec->height * ost->original_bottomBand / ost->original_height) & ~1;
1050 leftBand = ((int64_t)ist->st->codec->width * ost->original_leftBand / ost->original_width) & ~1;
1051 rightBand = ((int64_t)ist->st->codec->width * ost->original_rightBand / ost->original_width) & ~1;
1059 ost->topBand = topBand;
1060 ost->bottomBand = bottomBand;
1061 ost->leftBand = leftBand;
1062 ost->rightBand = rightBand;
1064 ost->resample_height = ist->st->codec->height - (ost->topBand + ost->bottomBand);
1065 ost->resample_width = ist->st->codec->width - (ost->leftBand + ost->rightBand);
1066 ost->resample_pix_fmt= ist->st->codec->pix_fmt;
1069 sws_freeContext(ost->img_resample_ctx);
1071 ost->img_resample_ctx = sws_getContext(
1072 ist->st->codec->width - (ost->leftBand + ost->rightBand),
1073 ist->st->codec->height - (ost->topBand + ost->bottomBand),
1075 ost->st->codec->width - (ost->padleft + ost->padright),
1076 ost->st->codec->height - (ost->padtop + ost->padbottom),
1077 ost->st->codec->pix_fmt,
1079 if (ost->img_resample_ctx == NULL) {
1084 sws_scale(ost->img_resample_ctx, formatted_picture->data, formatted_picture->linesize,
1085 0, ost->resample_height, resampling_dst->data, resampling_dst->linesize);
1088 if (ost->video_pad) {
1091 ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
1098 pkt.stream_index= ost->index;
1108 pkt.pts= av_rescale_q(ost->sync_opts, enc->time_base, ost->st->time_base);
1111 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
1132 big_picture.quality = ost->st->quality;
1136 big_picture.pts= ost->sync_opts;
1137 // big_picture.pts= av_rescale(ost->sync_opts, AV_TIME_BASE*(int64_t)enc->time_base.num, enc->time_base.den);
1138 //av_log(NULL, AV_LOG_DEBUG, "%"PRId64" -> encoder\n", ost->sync_opts);
1151 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
1158 write_frame(s, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
1164 if (ost->logfile && enc->stats_out) {
1165 fprintf(ost->logfile, "%s", enc->stats_out);
1169 ost->sync_opts++;
1170 ost->frame_number++;
1178 static void do_video_stats(AVFormatContext *os, AVOutputStream *ost,
1194 enc = ost->st->codec;
1196 frame_number = ost->frame_number;
1203 ti1 = ost->sync_opts * av_q2d(enc->time_base);
1220 AVOutputStream *ost;
1253 ost = ost_table[i];
1254 enc = ost->st->codec;
1257 !ost->st->stream_copy ?
1263 frame_number = ost->frame_number;
1266 !ost->st->stream_copy ?
1302 pts = (double)ost->st->pts.val * av_q2d(ost->st->time_base);
1344 AVOutputStream *ost;
1507 ost = ost_table[i];
1508 if (ost->source_index == ist_index) {
1509 os = output_files[ost->file_index];
1512 //ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index] - start_time)/ AV_TIME_BASE;
1514 if (ost->encoding_needed) {
1516 switch(ost->st->codec->codec_type) {
1518 do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
1521 do_video_out(os, ost, ist, &picture, &frame_size);
1523 do_video_stats(os, ost, frame_size);
1526 do_subtitle_out(os, ost, ist, &subtitle,
1535 int64_t ost_tb_start_time= av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base);
1539 if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && !copy_initial_nonkeyframes)
1546 ost->st->codec->coded_frame= &avframe;
1549 if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
1551 else if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
1553 ost->sync_opts++;
1556 opkt.stream_index= ost->index;
1558 opkt.pts= av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time;
1563 opkt.dts = av_rescale_q(ist->pts, AV_TIME_BASE_Q, ost->st->time_base);
1565 opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base);
1568 opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base);
1572 if( ost->st->codec->codec_id != CODEC_ID_H264
1573 && ost->st->codec->codec_id != CODEC_ID_MPEG1VIDEO
1574 && ost->st->codec->codec_id != CODEC_ID_MPEG2VIDEO
1576 if(av_parser_change(ist->st->parser, ost->st->codec, &opkt.data, &opkt.size, data_buf, data_size, pkt->flags & AV_PKT_FLAG_KEY))
1583 write_frame(os, &opkt, ost->st->codec, bitstream_filters[ost->file_index][opkt.stream_index]);
1584 ost->st->codec->frame_number++;
1585 ost->frame_number++;
1610 ost = ost_table[i];
1611 if (ost->source_index == ist_index) {
1612 AVCodecContext *enc= ost->st->codec;
1613 os = output_files[ost->file_index];
1615 if(ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <=1)
1617 if(ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE))
1620 if (ost->encoding_needed) {
1625 pkt.stream_index= ost->index;
1627 switch(ost->st->codec->codec_type) {
1629 fifo_bytes = av_fifo_size(ost->fifo);
1636 av_fifo_generic_read(ost->fifo, samples, fifo_bytes, NULL);
1647 pkt.duration = av_rescale((int64_t)enc->frame_size*ost->st->time_base.den,
1648 ost->st->time_base.num, enc->sample_rate);
1670 if (ost->logfile && enc->stats_out) {
1671 fprintf(ost->logfile, "%s", enc->stats_out);
1683 pkt.pts= av_rescale_q(enc->coded_frame->pts, enc->time_base, ost->st->time_base);
1684 write_frame(os, &pkt, ost->st->codec, bitstream_filters[ost->file_index][pkt.stream_index]);
1758 AVOutputStream *ost, **ost_table = NULL;
1847 ost = av_mallocz(sizeof(AVOutputStream));
1848 if (!ost)
1850 ost_table[i] = ost;
1858 ost = ost_table[n];
1859 ost->file_index = k;
1860 ost->index = i;
1861 ost->st = os->streams[i];
1863 ost->source_index = file_table[stream_maps[n].file_index].ist_index +
1867 if (ist_table[ost->source_index]->st->codec->codec_type != ost->st->codec->codec_type) {
1868 int i= ost->file_index;
1872 ost->file_index, ost->index);
1897 ist->st->codec->codec_type == ost->st->codec->codec_type) {
1900 ost->source_index = j;
1911 if ( ist->st->codec->codec_type == ost->st->codec->codec_type
1913 ost->source_index = j;
1919 int i= ost->file_index;
1922 ost->file_index, ost->index);
1927 ist = ist_table[ost->source_index];
1929 ost->sync_ist = (nb_stream_maps > 0) ?
1938 ost = ost_table[i];
1939 os = output_files[ost->file_index];
1940 ist = ist_table[ost->source_index];
1942 codec = ost->st->codec;
1946 av_metadata_set2(&ost->st->metadata, t->key, t->value, AV_METADATA_DONT_OVERWRITE);
1949 ost->st->disposition = ist->st->disposition;
1953 if (ost->st->stream_copy) {
2005 ost->fifo= av_fifo_alloc(1024);
2006 if(!ost->fifo)
2008 ost->reformat_pair = MAKE_SFMT_PAIR(SAMPLE_FMT_NONE,SAMPLE_FMT_NONE);
2009 ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
2012 ost->encoding_needed = 1;
2015 if (ost->st->codec->pix_fmt == PIX_FMT_NONE) {
2019 ost->video_crop = ((frame_leftBand + frame_rightBand + frame_topBand + frame_bottomBand) != 0);
2020 ost->video_pad = ((frame_padleft + frame_padright + frame_padtop + frame_padbottom) != 0);
2021 ost->video_resample = ((codec->width != icodec->width -
2028 if (ost->video_crop) {
2029 ost->topBand = ost->original_topBand = frame_topBand;
2030 ost->bottomBand = ost->original_bottomBand = frame_bottomBand;
2031 ost->leftBand = ost->original_leftBand = frame_leftBand;
2032 ost->rightBand = ost->original_rightBand = frame_rightBand;
2034 if (ost->video_pad) {
2035 ost->padtop = frame_padtop;
2036 ost->padleft = frame_padleft;
2037 ost->padbottom = frame_padbottom;
2038 ost->padright = frame_padright;
2039 if (!ost->video_resample) {
2040 avcodec_get_frame_defaults(&ost->pict_tmp);
2041 if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
2046 if (ost->video_resample) {
2047 avcodec_get_frame_defaults(&ost->pict_tmp);
2048 if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
2054 ost->img_resample_ctx = sws_getContext(
2062 if (ost->img_resample_ctx == NULL) {
2067 ost->original_height = icodec->height;
2068 ost->original_width = icodec->width;
2072 ost->resample_height = icodec->height - (frame_topBand + frame_bottomBand);
2073 ost->resample_width = icodec->width - (frame_leftBand + frame_rightBand);
2074 ost->resample_pix_fmt= icodec->pix_fmt;
2075 ost->encoding_needed = 1;
2079 ost->encoding_needed = 1;
2087 if (ost->encoding_needed &&
2101 ost->logfile = f;
2130 ost = ost_table[i];
2131 if (ost->encoding_needed) {
2134 codec = avcodec_find_encoder(ost->st->codec->codec_id);
2137 ost->st->codec->codec_id, ost->file_index, ost->index);
2141 if (avcodec_open(ost->st->codec, codec) < 0) {
2143 ost->file_index, ost->index);
2147 extra_size += ost->st->codec->extradata_size;
2251 ost = ost_table[i];
2253 ist_table[ost->source_index]->file_index,
2254 ist_table[ost->source_index]->index,
2255 ost->file_index,
2256 ost->index);
2257 if (ost->sync_ist != ist_table[ost->source_index])
2259 ost->sync_ist->file_index,
2260 ost->sync_ist->index);
2306 ost = ost_table[i];
2307 os = output_files[ost->file_index];
2308 ist = ist_table[ost->source_index];
2311 opts = ost->st->pts.val * av_q2d(ost->st->time_base);
2323 if(ost->frame_number >= max_frames[ost->st->codec->codec_type]){
2448 ost = ost_table[i];
2449 if (ost->encoding_needed) {
2450 av_freep(&ost->st->codec->stats_in);
2451 avcodec_close(ost->st->codec);
2479 ost = ost_table[i];
2480 if (ost) {
2481 if (ost->logfile) {
2482 fclose(ost->logfile);
2483 ost->logfile = NULL;
2485 av_fifo_free(ost->fifo); /* works even if fifo is not
2487 av_free(ost->pict_tmp.data[0]);
2488 if (ost->video_resample)
2489 sws_freeContext(ost->img_resample_ctx);
2490 if (ost->resample)
2491 audio_resample_close(ost->resample);
2492 if (ost->reformat_ctx)
2493 av_audio_convert_free(ost->reformat_ctx);
2494 av_free(ost);