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

Lines Matching refs:avctx

289 static int audio_get_buffer(AVCodecContext *avctx, AVFrame *frame)
291 AVCodecInternal *avci = avctx->internal;
295 buf_size = av_samples_get_buffer_size(NULL, avctx->channels,
296 frame->nb_samples, avctx->sample_fmt,
322 if (buf->nb_channels != avctx->channels) {
337 if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
338 avctx->sample_fmt, buf->data[0],
348 buf->nb_channels = avctx->channels;
358 if (avctx->pkt) frame->pkt_pts = avctx->pkt->pts;
360 frame->reordered_opaque = avctx->reordered_opaque;
362 if (avctx->debug & FF_DEBUG_BUFFERS)
363 av_log(avctx, AV_LOG_DEBUG, "default_get_buffer called on frame %p, "
497 int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame)
499 switch (avctx->codec_type) {
501 return video_get_buffer(avctx, frame);
503 return audio_get_buffer(avctx, frame);
629 int attribute_align_arg avcodec_open(AVCodecContext *avctx, AVCodec *codec)
631 return avcodec_open2(avctx, codec, NULL);
635 int attribute_align_arg avcodec_open2(AVCodecContext *avctx, AVCodec *codec, AVDictionary **options)
640 if (avcodec_is_open(avctx))
643 if ((!codec && !avctx->codec)) {
644 av_log(avctx, AV_LOG_ERROR, "No codec provided to avcodec_open2().\n");
647 if ((codec && avctx->codec && codec != avctx->codec)) {
648 av_log(avctx, AV_LOG_ERROR, "This AVCodecContext was allocated for %s, "
649 "but %s passed to avcodec_open2().\n", avctx->codec->name, codec->name);
653 codec = avctx->codec;
655 if (avctx->extradata_size < 0 || avctx->extradata_size >= FF_MAX_EXTRADATA_SIZE)
669 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
674 avctx->internal = av_mallocz(sizeof(AVCodecInternal));
675 if (!avctx->internal) {
681 if(!avctx->priv_data){
682 avctx->priv_data = av_mallocz(codec->priv_data_size);
683 if (!avctx->priv_data) {
688 *(AVClass**)avctx->priv_data= codec->priv_class;
689 av_opt_set_defaults(avctx->priv_data);
692 if (codec->priv_class && (ret = av_opt_set_dict(avctx->priv_data, &tmp)) < 0)
695 avctx->priv_data = NULL;
697 if ((ret = av_opt_set_dict(avctx, &tmp)) < 0)
700 if(avctx->coded_width && avctx->coded_height)
701 avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
702 else if(avctx->width && avctx->height)
703 avcodec_set_dimensions(avctx, avctx->width, avctx->height);
705 if ((avctx->coded_width || avctx->coded_height || avctx->width || avctx->height)
706 && ( av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx) < 0
707 || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0)) {
708 av_log(avctx, AV_LOG_WARNING, "ignoring invalid width/height values\n");
709 avcodec_set_dimensions(avctx, 0, 0);
715 av_freep(&avctx->subtitle_header);
718 if (avctx->channels > SANE_NB_CHANNELS) {
723 avctx->codec = codec;
724 if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
725 avctx->codec_id == CODEC_ID_NONE) {
726 avctx->codec_type = codec->type;
727 avctx->codec_id = codec->id;
729 if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
730 && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
731 av_log(avctx, AV_LOG_ERROR, "codec type or id mismatches\n");
735 avctx->frame_number = 0;
738 av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition separate: %d; %d\n",
739 avctx->error_recognition, avctx->err_recognition);
742 avctx->err_recognition |= (1<<(avctx->error_recognition-(avctx->error_recognition>=FF_ER_VERY_AGGRESSIVE))) - 1;
743 av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition combined: %d; %d\n",
744 avctx->error_recognition, avctx->err_recognition);
747 if (avctx->codec_type == AVMEDIA_TYPE_AUDIO &&
748 (!avctx->time_base.num || !avctx->time_base.den)) {
749 avctx->time_base.num = 1;
750 avctx->time_base.den = avctx->sample_rate;
753 if (HAVE_THREADS && !avctx->thread_opaque) {
754 ret = ff_thread_init(avctx);
760 avctx->thread_count = 1;
762 if (avctx->codec->max_lowres < avctx->lowres) {
763 av_log(avctx, AV_LOG_ERROR, "The maximum value for lowres supported by the decoder is %d\n",
764 avctx->codec->max_lowres);
768 if (codec_is_encoder(avctx->codec)) {
770 if (avctx->codec->sample_fmts) {
771 for (i = 0; avctx->codec->sample_fmts[i] != AV_SAMPLE_FMT_NONE; i++)
772 if (avctx->sample_fmt == avctx->codec->sample_fmts[i])
774 if (avctx->codec->sample_fmts[i] == AV_SAMPLE_FMT_NONE) {
775 av_log(avctx, AV_LOG_ERROR, "Specified sample_fmt is not supported.\n");
780 if (avctx->codec->supported_samplerates) {
781 for (i = 0; avctx->codec->supported_samplerates[i] != 0; i++)
782 if (avctx->sample_rate == avctx->codec->supported_samplerates[i])
784 if (avctx->codec->supported_samplerates[i] == 0) {
785 av_log(avctx, AV_LOG_ERROR, "Specified sample_rate is not supported\n");
790 if (avctx->codec->channel_layouts) {
791 if (!avctx->channel_layout) {
792 av_log(avctx, AV_LOG_WARNING, "channel_layout not specified\n");
794 for (i = 0; avctx->codec->channel_layouts[i] != 0; i++)
795 if (avctx->channel_layout == avctx->codec->channel_layouts[i])
797 if (avctx->codec->channel_layouts[i] == 0) {
798 av_log(avctx, AV_LOG_ERROR, "Specified channel_layout is not supported\n");
804 if (avctx->channel_layout && avctx->channels) {
805 if (av_get_channel_layout_nb_channels(avctx->channel_layout) != avctx->channels) {
806 av_log(avctx, AV_LOG_ERROR, "channel layout does not match number of channels\n");
810 } else if (avctx->channel_layout) {
811 avctx->channels = av_get_channel_layout_nb_channels(avctx->channel_layout);
815 if(avctx->codec->init && !(avctx->active_thread_type&FF_THREAD_FRAME)){
816 ret = avctx->codec->init(avctx);
836 av_freep(&avctx->priv_data);
837 av_freep(&avctx->internal);
838 avctx->codec= NULL;
865 int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
874 if (!(avctx->codec->capabilities & CODEC_CAP_DELAY) && !frame) {
883 if (avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
884 if (nb_samples > avctx->frame_size)
886 } else if (!(avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE)) {
887 if (nb_samples != avctx->frame_size)
891 nb_samples = avctx->frame_size;
894 if (avctx->codec->encode2) {
896 ret = avctx->codec->encode2(avctx, avpkt, frame, got_packet_ptr);
898 !(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
901 (AVRational){ 1, avctx->sample_rate },
902 avctx->time_base);
911 if (avctx->codec->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE) {
912 av_assert0(av_get_bits_per_sample(avctx->codec_id) != 0);
913 buf_size = nb_samples * avctx->channels *
914 av_get_bits_per_sample(avctx->codec_id) / 8;
919 buf_size = 2 * avctx->frame_size * avctx->channels *
920 av_get_bytes_per_sample(avctx->sample_fmt);
928 CODEC_CAP_SMALL_LAST_FRAME require avctx->frame_size to be set to
932 if ((avctx->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) &&
933 nb_samples < avctx->frame_size) {
934 fs_tmp = avctx->frame_size;
935 avctx->frame_size = nb_samples;
939 ret = avctx->codec->encode(avctx, avpkt->data, avpkt->size,
948 if (avctx->coded_frame)
949 avpkt->pts = avctx->coded_frame->pts;
954 avpkt->duration = av_rescale_q(avctx->frame_size,
955 (AVRational){ 1, avctx->sample_rate },
956 avctx->time_base);
965 avctx->frame_size = fs_tmp;
968 avctx->frame_number++;
979 int attribute_align_arg avcodec_encode_audio(AVCodecContext *avctx,
996 if (avctx->frame_size) {
997 frame->nb_samples = avctx->frame_size;
1002 if (!av_get_bits_per_sample(avctx->codec_id)) {
1003 av_log(avctx, AV_LOG_ERROR, "avcodec_encode_audio() does not "
1008 (av_get_bits_per_sample(avctx->codec_id) *
1009 avctx->channels);
1017 samples_size = av_samples_get_buffer_size(NULL, avctx->channels,
1019 avctx->sample_fmt, 1);
1020 if ((ret = avcodec_fill_audio_frame(frame, avctx->channels,
1021 avctx->sample_fmt,
1028 frame->pts = av_rescale_q(avctx->internal->sample_count,
1029 (AVRational){ 1, avctx->sample_rate },
1030 avctx->time_base);
1031 avctx->internal->sample_count += frame->nb_samples;
1037 ret = avcodec_encode_audio2(avctx, &pkt, frame, &got_packet);
1038 if (!ret && got_packet && avctx->coded_frame) {
1039 avctx->coded_frame->pts = pkt.pts;
1040 avctx->coded_frame->key_frame = !!(pkt.flags & AV_PKT_FLAG_KEY);
1058 int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1062 av_log(avctx, AV_LOG_ERROR, "buffer smaller than minimum size\n");
1065 if(av_image_check_size(avctx->width, avctx->height, 0, avctx))
1067 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || pict){
1068 int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
1069 avctx->frame_number++;
1077 int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size,
1082 av_log(avctx, AV_LOG_ERROR, "start_display_time must be 0.\n");
1087 ret = avctx->codec->encode(avctx, buf, buf_size, sub);
1088 avctx->frame_number++;
1092 static void apply_param_change(AVCodecContext *avctx, AVPacket *avpkt)
1098 if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE))
1109 avctx->channels = bytestream_get_le32(&data);
1115 avctx->channel_layout = bytestream_get_le64(&data);
1121 avctx->sample_rate = bytestream_get_le32(&data);
1127 avctx->width = bytestream_get_le32(&data);
1128 avctx->height = bytestream_get_le32(&data);
1129 avcodec_set_dimensions(avctx, avctx->width, avctx->height);
1134 int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
1141 if((avctx->coded_width||avctx->coded_height) && av_image_check_size(avctx->coded_width, avctx->coded_height, 0, avctx))
1144 avctx->pkt = avpkt;
1145 apply_param_change(avctx, avpkt);
1147 if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){
1148 if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
1149 ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
1152 ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
1155 picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
1156 picture->width = avctx->width;
1157 picture->height = avctx->height;
1158 picture->format = avctx->pix_fmt;
1164 avctx->frame_number++;
1172 int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples,
1179 if (avctx->get_buffer != avcodec_default_get_buffer) {
1180 av_log(avctx, AV_LOG_ERROR, "Custom get_buffer() for use with"
1182 av_log(avctx, AV_LOG_ERROR, "Please port your application to "
1184 avctx->get_buffer = avcodec_default_get_buffer;
1187 ret = avcodec_decode_audio4(avctx, &frame, &got_frame, avpkt);
1191 int planar = av_sample_fmt_is_planar(avctx->sample_fmt);
1192 int data_size = av_samples_get_buffer_size(&plane_size, avctx->channels,
1194 avctx->sample_fmt, 1);
1196 av_log(avctx, AV_LOG_ERROR, "output buffer size is too small for "
1203 if (planar && avctx->channels > 1) {
1205 for (ch = 1; ch < avctx->channels; ch++) {
1218 int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
1227 avctx->pkt = avpkt;
1230 av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
1234 apply_param_change(avctx, avpkt);
1236 if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
1237 ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt);
1239 avctx->frame_number++;
1242 frame->format = avctx->sample_fmt;
1248 int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
1254 avctx->pkt = avpkt;
1256 ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
1258 avctx->frame_number++;
1282 av_cold int avcodec_close(AVCodecContext *avctx)
1292 av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
1297 if (avcodec_is_open(avctx)) {
1298 if (HAVE_THREADS && avctx->thread_opaque)
1299 ff_thread_free(avctx);
1300 if (avctx->codec && avctx->codec->close)
1301 avctx->codec->close(avctx);
1302 avcodec_default_free_buffers(avctx);
1303 avctx->coded_frame = NULL;
1304 av_freep(&avctx->internal);
1307 if (avctx->priv_data && avctx->codec && avctx->codec->priv_class)
1308 av_opt_free(avctx->priv_data);
1309 av_opt_free(avctx);
1310 av_freep(&avctx->priv_data);
1311 if (codec_is_encoder(avctx->codec))
1312 av_freep(&avctx->extradata);
1313 avctx->codec = NULL;
1314 avctx->active_thread_type = 0;
1563 void avcodec_flush_buffers(AVCodecContext *avctx)
1565 if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME)
1566 ff_thread_flush(avctx);
1567 else if(avctx->codec->flush)
1568 avctx->codec->flush(avctx);
1594 static void audio_free_buffers(AVCodecContext *avctx)
1596 AVCodecInternal *avci = avctx->internal;
1611 void avcodec_default_free_buffers(AVCodecContext *avctx)
1613 switch (avctx->codec_type) {
1615 video_free_buffers(avctx);
1618 audio_free_buffers(avctx);
1812 int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f)
1814 f->owner = avctx;
1815 return avctx->get_buffer(avctx, f);
1818 void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f)
1823 void ff_thread_finish_setup(AVCodecContext *avctx)