| 781 | } |
| 782 | |
| 783 | static int frame_encode(OutputStream *ost, AVFrame *frame, AVPacket *pkt) |
| 784 | { |
| 785 | Encoder *e = ost->enc; |
| 786 | OutputFile *of = ost->file; |
| 787 | enum AVMediaType type = ost->type; |
| 788 | |
| 789 | if (type == AVMEDIA_TYPE_SUBTITLE) { |
| 790 | const AVSubtitle *subtitle = frame && frame->buf[0] ? |
| 791 | (AVSubtitle*)frame->buf[0]->data : NULL; |
| 792 | |
| 793 | // no flushing for subtitles |
| 794 | return subtitle && subtitle->num_rects ? |
| 795 | do_subtitle_out(of, ost, subtitle, pkt) : 0; |
| 796 | } |
| 797 | |
| 798 | if (frame) { |
| 799 | if (!check_recording_time(ost, frame->pts, frame->time_base)) |
| 800 | return AVERROR_EOF; |
| 801 | |
| 802 | if (type == AVMEDIA_TYPE_VIDEO) { |
| 803 | frame->quality = e->enc_ctx->global_quality; |
| 804 | frame->pict_type = forced_kf_apply(e, &ost->kf, frame); |
| 805 | |
| 806 | #if FFMPEG_OPT_TOP |
| 807 | if (ost->top_field_first >= 0) { |
| 808 | frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST; |
| 809 | frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST * (!!ost->top_field_first); |
| 810 | } |
| 811 | #endif |
| 812 | } else { |
| 813 | if (!(e->enc_ctx->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && |
| 814 | e->enc_ctx->ch_layout.nb_channels != frame->ch_layout.nb_channels) { |
| 815 | av_log(e, AV_LOG_ERROR, |
| 816 | "Audio channel count changed and encoder does not support parameter changes\n"); |
| 817 | return 0; |
| 818 | } |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | return encode_frame(of, ost, frame, pkt); |
| 823 | } |
| 824 | |
| 825 | static void enc_thread_set_name(const OutputStream *ost) |
| 826 | { |
no test coverage detected