summaryrefslogtreecommitdiff
path: root/ffmpeg/doc/examples/decoding_encoding.c
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-29 12:19:38 +0000
commitf7813a5324be39d13ab536c245d15dfc602a7849 (patch)
treefad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/doc/examples/decoding_encoding.c
parentb7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff)
basic type mechanism working
Diffstat (limited to 'ffmpeg/doc/examples/decoding_encoding.c')
-rw-r--r--ffmpeg/doc/examples/decoding_encoding.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/ffmpeg/doc/examples/decoding_encoding.c b/ffmpeg/doc/examples/decoding_encoding.c
index ae1057c..08e8b92 100644
--- a/ffmpeg/doc/examples/decoding_encoding.c
+++ b/ffmpeg/doc/examples/decoding_encoding.c
@@ -79,7 +79,7 @@ static int select_channel_layout(AVCodec *codec)
{
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;
@@ -88,9 +88,9 @@ static int select_channel_layout(AVCodec *codec)
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++;
}
@@ -156,7 +156,7 @@ static void audio_encode_example(const char *filename)
}
/* 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);
@@ -170,6 +170,10 @@ static void audio_encode_example(const char *filename)
* we calculate the size of the samples buffer in bytes */
buffer_size = av_samples_get_buffer_size(NULL, c->channels, c->frame_size,
c->sample_fmt, 0);
+ if (buffer_size < 0) {
+ fprintf(stderr, "Could not get sample buffer size\n");
+ exit(1);
+ }
samples = av_malloc(buffer_size);
if (!samples) {
fprintf(stderr, "Could not allocate %d bytes for samples buffer\n",
@@ -227,7 +231,7 @@ static void audio_encode_example(const char *filename)
fclose(f);
av_freep(&samples);
- avcodec_free_frame(&frame);
+ av_frame_free(&frame);
avcodec_close(c);
av_free(c);
}
@@ -287,12 +291,11 @@ static void audio_decode_example(const char *outfilename, const char *filename)
int got_frame = 0;
if (!decoded_frame) {
- if (!(decoded_frame = avcodec_alloc_frame())) {
+ if (!(decoded_frame = av_frame_alloc())) {
fprintf(stderr, "Could not allocate audio frame\n");
exit(1);
}
- } else
- avcodec_get_frame_defaults(decoded_frame);
+ }
len = avcodec_decode_audio4(c, decoded_frame, &got_frame, &avpkt);
if (len < 0) {
@@ -329,7 +332,7 @@ static void audio_decode_example(const char *outfilename, const char *filename)
avcodec_close(c);
av_free(c);
- avcodec_free_frame(&decoded_frame);
+ av_frame_free(&decoded_frame);
}
/*
@@ -386,7 +389,7 @@ static void video_encode_example(const char *filename, int codec_id)
exit(1);
}
- frame = avcodec_alloc_frame();
+ frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
@@ -467,7 +470,7 @@ static void video_encode_example(const char *filename, int codec_id)
avcodec_close(c);
av_free(c);
av_freep(&frame->data[0]);
- avcodec_free_frame(&frame);
+ av_frame_free(&frame);
printf("\n");
}
@@ -565,7 +568,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
exit(1);
}
- frame = avcodec_alloc_frame();
+ frame = av_frame_alloc();
if (!frame) {
fprintf(stderr, "Could not allocate video frame\n");
exit(1);
@@ -609,7 +612,7 @@ static void video_decode_example(const char *outfilename, const char *filename)
avcodec_close(c);
av_free(c);
- avcodec_free_frame(&frame);
+ av_frame_free(&frame);
printf("\n");
}