#endif
#include "libavcodec/avcodec.h"
-#include "libavutil/audioconvert.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
#include "libavutil/imgutils.h"
#include "libavutil/mathematics.h"
#include "libavutil/samplefmt.h"
{
const uint64_t *p;
uint64_t best_ch_layout = 0;
- int best_nb_channells = 0;
+ int best_nb_channels = 0;
if (!codec->channel_layouts)
return AV_CH_LAYOUT_STEREO;
while (*p) {
int nb_channels = av_get_channel_layout_nb_channels(*p);
- if (nb_channels > best_nb_channells) {
+ if (nb_channels > best_nb_channels) {
best_ch_layout = *p;
- best_nb_channells = nb_channels;
+ best_nb_channels = nb_channels;
}
p++;
}
}
/* frame containing input raw audio */
- frame = avcodec_alloc_frame();
+ frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "could not allocate audio frame\n");
exit(1);
fclose(f);
av_freep(&samples);
- av_freep(&frame);
+ av_frame_free(&frame);
avcodec_close(c);
av_free(c);
}
int got_frame = 0;
if (!decoded_frame) {
- if (!(decoded_frame = avcodec_alloc_frame())) {
+ if (!(decoded_frame = av_frame_alloc())) {
fprintf(stderr, "out of memory\n");
exit(1);
}
- } else
- avcodec_get_frame_defaults(decoded_frame);
+ }
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
if (len < 0) {
avcodec_close(c);
av_free(c);
- av_free(decoded_frame);
+ av_frame_free(&decoded_frame);
}
/*
}
c = avcodec_alloc_context3(codec);
- picture= avcodec_alloc_frame();
+ picture = av_frame_alloc();
/* put sample parameters */
c->bit_rate = 400000;
c->time_base= (AVRational){1,25};
c->gop_size = 10; /* emit one intra frame every ten frames */
c->max_b_frames=1;
- c->pix_fmt = PIX_FMT_YUV420P;
+ c->pix_fmt = AV_PIX_FMT_YUV420P;
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
avcodec_close(c);
av_free(c);
av_freep(&picture->data[0]);
- av_free(picture);
+ av_frame_free(&picture);
printf("\n");
}
}
c = avcodec_alloc_context3(codec);
- picture= avcodec_alloc_frame();
+ picture = av_frame_alloc();
if(codec->capabilities&CODEC_CAP_TRUNCATED)
c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */
avcodec_close(c);
av_free(c);
- av_free(picture);
+ av_frame_free(&picture);
printf("\n");
}