char opt_stripped[128];
const char *p;
const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class();
- const av_unused AVClass *rc_class;
+ #if CONFIG_AVRESAMPLE
+ const AVClass *rc = avresample_get_class();
+ #endif
-#if CONFIG_SWSCALE
- const AVClass *sc = sws_get_class();
-#endif
+ const AVClass *sc, *swr_class;
+
+ if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug"))
+ av_log_set_level(AV_LOG_DEBUG);
if (!(p = strchr(opt, ':')))
p = opt + strlen(opt);
av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
return ret;
}
- rc_class = avresample_get_class();
- if ((o=av_opt_find(&rc_class, opt, NULL, 0,
+ consumed = 1;
+ }
+#endif
+#if CONFIG_SWRESAMPLE
+ swr_class = swr_get_class();
+ if (!consumed && (o=av_opt_find(&swr_class, opt, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
+ struct SwrContext *swr = swr_alloc();
+ int ret = av_opt_set(swr, opt, arg, 0);
+ swr_free(&swr);
+ if (ret < 0) {
+ av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt);
+ return ret;
+ }
+ av_dict_set(&swr_opts, opt, arg, FLAGS);
+ consumed = 1;
+ }
+#endif
+#if CONFIG_AVRESAMPLE
++ if ((o=av_opt_find(&rc, opt, NULL, 0,
+ AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) {
+ av_dict_set(&resample_opts, opt, arg, FLAGS);
+ consumed = 1;
}
#endif
uv_height = y_height >> (SCHRO_FRAME_FORMAT_V_SHIFT(schro_frame_fmt));
p_pic = av_mallocz(sizeof(AVPicture));
- if (!p_pic || avpicture_alloc(p_pic, avccontext->pix_fmt, y_width, y_height) < 0) {
- avpicture_alloc(p_pic, avctx->pix_fmt, y_width, y_height);
++ if (!p_pic || avpicture_alloc(p_pic, avctx->pix_fmt, y_width, y_height) < 0) {
+ av_free(p_pic);
+ return NULL;
+ }
p_frame = schro_frame_new();
p_frame->format = schro_frame_fmt;
p_schro_params->format = schro_decoder_get_video_format(decoder);
- /* Tell Libav about sequence details. */
+ /* Tell FFmpeg about sequence details. */
if (av_image_check_size(p_schro_params->format->width,
- p_schro_params->format->height, 0, avccontext) < 0) {
- av_log(avccontext, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
+ p_schro_params->format->height, 0, avctx) < 0) {
+ av_log(avctx, AV_LOG_ERROR, "invalid dimensions (%dx%d)\n",
p_schro_params->format->width, p_schro_params->format->height);
- avccontext->height = avccontext->width = 0;
+ avctx->height = avctx->width = 0;
return;
}
- avccontext->height = p_schro_params->format->height;
- avccontext->width = p_schro_params->format->width;
- avccontext->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format);
+ avctx->height = p_schro_params->format->height;
+ avctx->width = p_schro_params->format->width;
+ avctx->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format);
if (ff_get_schro_frame_format(p_schro_params->format->chroma_format,
&p_schro_params->frame_format) == -1) {
pkt_size = p_frame_output->size;
if (last_frame_in_sequence && p_schro_params->enc_buf_size > 0)
pkt_size += p_schro_params->enc_buf_size;
- if ((ret = ff_alloc_packet2(avccontext, pkt, pkt_size)) < 0)
- if ((ret = ff_alloc_packet(pkt, pkt_size)) < 0) {
- av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %d.\n", pkt_size);
++ if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size)) < 0)
goto error;
- }
memcpy(pkt->data, p_frame_output->p_encbuf, p_frame_output->size);
- avccontext->coded_frame->key_frame = p_frame_output->key_frame;
+ avctx->coded_frame->key_frame = p_frame_output->key_frame;
/* Use the frame number of the encoded frame as the pts. It is OK to
* do so since Dirac is a constant frame rate codec. It expects input
* to be of constant frame rate. */
return 1;
}
- static int vorbis_encode_frame(AVCodecContext *avccontext, AVPacket *avpkt,
-
+ static int vorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
- vorbis_enc_context *venc = avccontext->priv_data;
+ vorbis_enc_context *venc = avctx->priv_data;
float **audio = frame ? (float **)frame->extended_data : NULL;
int samples = frame ? frame->nb_samples : 0;
vorbis_enc_mode *mode;
return 0;
samples = 1 << (venc->log2_blocksize[0] - 1);
- if ((ret = ff_alloc_packet2(avccontext, avpkt, 8192)))
- if ((ret = ff_alloc_packet(avpkt, 8192))) {
- av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
++ if ((ret = ff_alloc_packet2(avctx, avpkt, 8192)))
return ret;
- }
init_put_bits(&pb, avpkt->data, avpkt->size);
flush_put_bits(&pb);
avpkt->size = put_bits_count(&pb) >> 3;
- avpkt->duration = ff_samples_to_time_base(avccontext, avccontext->frame_size);
+ avpkt->duration = ff_samples_to_time_base(avctx, avctx->frame_size);
- if (frame)
+ if (frame) {
if (frame->pts != AV_NOPTS_VALUE)
- avpkt->pts = ff_samples_to_time_base(avccontext, frame->pts);
+ avpkt->pts = ff_samples_to_time_base(avctx, frame->pts);
- else
+ } else
avpkt->pts = venc->next_pts;
if (avpkt->pts != AV_NOPTS_VALUE)
venc->next_pts = avpkt->pts + avpkt->duration;
return 0 ;
}
- static av_cold int vorbis_encode_init(AVCodecContext *avccontext)
+ static av_cold int vorbis_encode_init(AVCodecContext *avctx)
{
- vorbis_enc_context *venc = avccontext->priv_data;
+ vorbis_enc_context *venc = avctx->priv_data;
int ret;
- if (avccontext->channels != 2) {
- av_log(avccontext, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
+ if (avctx->channels != 2) {
- av_log(avctx, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n");
++ av_log(avctx, AV_LOG_ERROR, "Current FFmpeg Vorbis encoder only supports 2 channels.\n");
return -1;
}
- if ((ret = create_vorbis_context(venc, avccontext)) < 0)
+ if ((ret = create_vorbis_context(venc, avctx)) < 0)
goto error;
- avccontext->bit_rate = 0;
- if (avccontext->flags & CODEC_FLAG_QSCALE)
- venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA;
+ avctx->bit_rate = 0;
+ if (avctx->flags & CODEC_FLAG_QSCALE)
+ venc->quality = avctx->global_quality / (float)FF_QP2LAMBDA;
else
- venc->quality = 3.0;
+ venc->quality = 8;
venc->quality *= venc->quality;
- if ((ret = put_main_header(venc, (uint8_t**)&avccontext->extradata)) < 0)
+ if ((ret = put_main_header(venc, (uint8_t**)&avctx->extradata)) < 0)
goto error;
- avccontext->extradata_size = ret;
+ avctx->extradata_size = ret;
- avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1);
+ avctx->frame_size = 1 << (venc->log2_blocksize[0] - 1);
#if FF_API_OLD_ENCODE_AUDIO
- avccontext->coded_frame = avcodec_alloc_frame();
- if (!avccontext->coded_frame) {
+ avctx->coded_frame = avcodec_alloc_frame();
+ if (!avctx->coded_frame) {
ret = AVERROR(ENOMEM);
goto error;
}