Lines Matching defs:avctx
98 static int xvid_encode_close(AVCodecContext *avctx);
99 static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
275 * @param avctx AVCodecContext pointer to context
281 static int xvid_strip_vol_header(AVCodecContext *avctx, AVPacket *pkt,
299 if (!avctx->extradata) {
300 avctx->extradata = av_malloc(vo_len);
301 if (!avctx->extradata)
303 memcpy(avctx->extradata, pkt->data, vo_len);
304 avctx->extradata_size = vo_len;
321 * @param avctx Context that contains the framerate to correct.
323 static void xvid_correct_framerate(AVCodecContext *avctx)
330 frate = avctx->time_base.den;
331 fbase = avctx->time_base.num;
340 avctx->time_base.den = frate;
341 avctx->time_base.num = fbase;
362 avctx->time_base.den = est_frate;
363 avctx->time_base.num = est_fbase;
364 av_log(avctx, AV_LOG_DEBUG,
368 avctx->time_base.den = frate;
369 avctx->time_base.num = fbase;
373 static av_cold int xvid_encode_init(AVCodecContext *avctx)
376 int xvid_flags = avctx->flags;
377 struct xvid_context *x = avctx->priv_data;
397 if (avctx->trellis)
424 switch (avctx->mb_decision) {
465 x->xsize = avctx->width;
467 x->ysize = avctx->height;
476 xvid_enc_create.num_threads = avctx->thread_count;
479 if (avctx->height <= 16) {
480 if (avctx->thread_count < 2) {
483 av_log(avctx, AV_LOG_ERROR,
504 av_log(avctx, AV_LOG_ERROR,
516 rc2pass2.bitrate = avctx->bit_rate;
518 fd = avpriv_tempfile("xvidff.", &x->twopassfile, 0, avctx);
520 av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n");
525 if (!avctx->stats_in) {
526 av_log(avctx, AV_LOG_ERROR,
531 ret = write(fd, avctx->stats_in, strlen(avctx->stats_in));
534 else if (strlen(avctx->stats_in) > ret) {
535 av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n");
548 single.bitrate = avctx->bit_rate;
555 if (avctx->lumi_masking != 0.0)
563 /* The old behavior is that when avctx->lumi_masking is specified,
566 avctx->lumi_masking ? NULL : &masking_l;
579 av_log(avctx, AV_LOG_INFO,
595 xvid_correct_framerate(avctx);
596 xvid_enc_create.fincr = avctx->time_base.num;
597 xvid_enc_create.fbase = avctx->time_base.den;
598 if (avctx->gop_size > 0)
599 xvid_enc_create.max_key_interval = avctx->gop_size;
609 xvid_enc_create.min_quant[0] = avctx->qmin;
610 xvid_enc_create.min_quant[1] = avctx->qmin;
611 xvid_enc_create.min_quant[2] = avctx->qmin;
612 xvid_enc_create.max_quant[0] = avctx->qmax;
613 xvid_enc_create.max_quant[1] = avctx->qmax;
614 xvid_enc_create.max_quant[2] = avctx->qmax;
622 if ((avctx->intra_matrix || avctx->inter_matrix)) {
625 if (avctx->intra_matrix) {
626 intra = avctx->intra_matrix;
632 if (avctx->inter_matrix) {
633 inter = avctx->inter_matrix;
655 avctx->extradata = NULL;
656 avctx->extradata_size = 0;
663 if (!avctx->codec_tag)
664 avctx->codec_tag = AV_RL32("xvid");
668 xvid_enc_create.max_bframes = avctx->max_b_frames;
669 xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset;
670 xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor;
671 if (avctx->max_b_frames > 0 && !x->quicktime_format)
696 av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
700 size = ((avctx->width + 1) & ~1) * ((avctx->height + 1) & ~1);
711 xvid_encode_frame(avctx, packet, picture, &got_packet);
721 av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n");
730 static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
734 struct xvid_context *x = avctx->priv_data;
735 int mb_width = (avctx->width + 15) / 16;
736 int mb_height = (avctx->height + 15) / 16;
742 if ((ret = ff_alloc_packet(avctx, pkt, mb_width*(int64_t)mb_height*MAX_MB_BYTES + AV_INPUT_BUFFER_MIN_SIZE)) < 0)
754 if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) {
755 av_log(avctx, AV_LOG_ERROR,
778 if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.num > 255 ||
779 avctx->sample_aspect_ratio.den < 0 || avctx->sample_aspect_ratio.den > 255) {
780 av_log(avctx, AV_LOG_WARNING,
782 avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den);
783 av_reduce(&avctx->sample_aspect_ratio.num, &avctx->sample_aspect_ratio.den,
784 avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den, 255);
787 xvid_enc_frame.par_width = avctx->sample_aspect_ratio.num;
788 xvid_enc_frame.par_height = avctx->sample_aspect_ratio.den;
805 avctx->stats_out = NULL;
812 avctx->stats_out = x->old_twopassbuffer;
835 return xvid_strip_vol_header(avctx, pkt,
845 av_log(avctx, AV_LOG_ERROR,
851 static av_cold int xvid_encode_close(AVCodecContext *avctx)
853 struct xvid_context *x = avctx->priv_data;
863 avctx->stats_out = NULL;