Re: [FFmpeg-devel] [PATCH 2/2] api-flac-test: Coding style

2015-04-22 Thread Michael Niedermayer
On Wed, Apr 22, 2015 at 06:09:15PM +0300, Ludmila Glinskih wrote:
> ---
>  libavcodec/api-flac-test.c | 72 
> --
>  1 file changed, 24 insertions(+), 48 deletions(-)

applied

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] api-flac-test: Coding style

2015-04-22 Thread Ludmila Glinskih
---
 libavcodec/api-flac-test.c | 72 --
 1 file changed, 24 insertions(+), 48 deletions(-)

diff --git a/libavcodec/api-flac-test.c b/libavcodec/api-flac-test.c
index 1540da9..5ff8f12 100644
--- a/libavcodec/api-flac-test.c
+++ b/libavcodec/api-flac-test.c
@@ -40,8 +40,7 @@ static int generate_raw_frame(uint16_t *frame_data, int i, 
int sample_rate,
 {
 int j, k;
 
-for (j = 0; j < frame_size; j++)
-{
+for (j = 0; j < frame_size; j++) {
 frame_data[channels * j] = 1 * ((j / 10 * i) % 2);
 for (k = 1; k < channels; k++)
 frame_data[channels * j + k] = frame_data[channels * j] * (k + 1);
@@ -60,8 +59,7 @@ static int init_encoder(AVCodec *enc, AVCodecContext 
**enc_ctx,
 av_log(NULL, AV_LOG_INFO, "channel layout: %s, sample rate: %i\n", 
name_buff, sample_rate);
 
 ctx = avcodec_alloc_context3(enc);
-if (!ctx)
-{
+if (!ctx) {
 av_log(NULL, AV_LOG_ERROR, "Can't allocate encoder context\n");
 return AVERROR(ENOMEM);
 }
@@ -71,8 +69,7 @@ static int init_encoder(AVCodec *enc, AVCodecContext 
**enc_ctx,
 ctx->channel_layout = ch_layout;
 
 result = avcodec_open2(ctx, enc, NULL);
-if (result < 0)
-{
+if (result < 0) {
 av_log(ctx, AV_LOG_ERROR, "Can't open encoder\n");
 return result;
 }
@@ -88,8 +85,7 @@ static int init_decoder(AVCodec *dec, AVCodecContext 
**dec_ctx,
 int result;
 
 ctx = avcodec_alloc_context3(dec);
-if (!ctx)
-{
+if (!ctx) {
 av_log(NULL, AV_LOG_ERROR , "Can't allocate decoder context\n");
 return AVERROR(ENOMEM);
 }
@@ -100,8 +96,7 @@ static int init_decoder(AVCodec *dec, AVCodecContext 
**dec_ctx,
 ctx->channel_layout = ch_layout;
 
 result = avcodec_open2(ctx, dec, NULL);
-if (result < 0)
-{
+if (result < 0) {
 av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n");
 return result;
 }
@@ -122,8 +117,7 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 int i = 0;
 
 in_frame = av_frame_alloc();
-if (!in_frame)
-{
+if (!in_frame) {
 av_log(NULL, AV_LOG_ERROR, "Can't allocate input frame\n");
 return AVERROR(ENOMEM);
 }
@@ -131,35 +125,30 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 in_frame->nb_samples = enc_ctx->frame_size;
 in_frame->format = enc_ctx->sample_fmt;
 in_frame->channel_layout = enc_ctx->channel_layout;
-if (av_frame_get_buffer(in_frame, 32) != 0)
-{
+if (av_frame_get_buffer(in_frame, 32) != 0) {
 av_log(NULL, AV_LOG_ERROR, "Can't allocate a buffer for input 
frame\n");
 return AVERROR(ENOMEM);
 }
 
 out_frame = av_frame_alloc();
-if (!out_frame)
-{
+if (!out_frame) {
 av_log(NULL, AV_LOG_ERROR, "Can't allocate output frame\n");
 return AVERROR(ENOMEM);
 }
 
 raw_in = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES);
-if (!raw_in)
-{
+if (!raw_in) {
 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_in\n");
 return AVERROR(ENOMEM);
 }
 
 raw_out = av_malloc(in_frame->linesize[0] * NUMBER_OF_FRAMES);
-if (!raw_out)
-{
+if (!raw_out) {
 av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for raw_out\n");
 return AVERROR(ENOMEM);
 }
 
-for (i = 0; i < NUMBER_OF_FRAMES; i++)
-{
+for (i = 0; i < NUMBER_OF_FRAMES; i++) {
 av_init_packet(&enc_pkt);
 enc_pkt.data = NULL;
 enc_pkt.size = 0;
@@ -169,44 +158,36 @@ static int run_test(AVCodec *enc, AVCodec *dec, 
AVCodecContext *enc_ctx,
 memcpy(raw_in + in_offset, in_frame->data[0], in_frame->linesize[0]);
 in_offset += in_frame->linesize[0];
 result = avcodec_encode_audio2(enc_ctx, &enc_pkt, in_frame, 
&got_output);
-if (result < 0)
-{
+if (result < 0) {
 av_log(NULL, AV_LOG_ERROR, "Error encoding audio frame\n");
 return result;
 }
 
 /* if we get an encoded packet, feed it straight to the decoder */
-if (got_output)
-{
+if (got_output) {
 result = avcodec_decode_audio4(dec_ctx, out_frame, &got_output, 
&enc_pkt);
-if (result < 0)
-{
+if (result < 0) {
 av_log(NULL, AV_LOG_ERROR, "Error decoding audio packet\n");
 return result;
 }
 
-if (got_output)
-{
-if (result != enc_pkt.size)
-{
+if (got_output) {
+if (result != enc_pkt.size) {
 av_log(NULL, AV_LOG_INFO, "Decoder consumed only part of a 
packet, it is allowed to do so -- need to update this test\n");
 return AVERROR_UNKNOWN;
 }
 
-if (in_frame->nb_samples != out_frame->nb_samples)
-