Browse code

atrac3: return appropriate error codes instead of -1

Justin Ruggles authored on 2011/10/29 02:00:53
Showing 1 changed files
... ...
@@ -376,7 +376,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
376 376
 
377 377
     coding_mode_selector = get_bits(gb,2);
378 378
     if (coding_mode_selector == 2)
379
-        return -1;
379
+        return AVERROR_INVALIDDATA;
380 380
 
381 381
     coding_mode = coding_mode_selector & 1;
382 382
 
... ...
@@ -388,7 +388,7 @@ static int decodeTonalComponents (GetBitContext *gb, tonal_component *pComponent
388 388
 
389 389
         quant_step_index = get_bits(gb,3);
390 390
         if (quant_step_index <= 1)
391
-            return -1;
391
+            return AVERROR_INVALIDDATA;
392 392
 
393 393
         if (coding_mode_selector == 3)
394 394
             coding_mode = get_bits1(gb);
... ...
@@ -451,7 +451,7 @@ static int decodeGainControl (GetBitContext *gb, gain_block *pGb, int numBands)
451 451
             pLevel[cf]= get_bits(gb,4);
452 452
             pLoc  [cf]= get_bits(gb,5);
453 453
             if(cf && pLoc[cf] <= pLoc[cf-1])
454
-                return -1;
454
+                return AVERROR_INVALIDDATA;
455 455
         }
456 456
     }
457 457
 
... ...
@@ -668,12 +668,12 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_
668 668
     if (codingMode == JOINT_STEREO && channelNum == 1) {
669 669
         if (get_bits(gb,2) != 3) {
670 670
             av_log(NULL,AV_LOG_ERROR,"JS mono Sound Unit id != 3.\n");
671
-            return -1;
671
+            return AVERROR_INVALIDDATA;
672 672
         }
673 673
     } else {
674 674
         if (get_bits(gb,6) != 0x28) {
675 675
             av_log(NULL,AV_LOG_ERROR,"Sound Unit id != 0x28.\n");
676
-            return -1;
676
+            return AVERROR_INVALIDDATA;
677 677
         }
678 678
     }
679 679
 
... ...
@@ -760,7 +760,7 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf,
760 760
         ptr1 = q->decoded_bytes_buffer;
761 761
         for (i = 4; *ptr1 == 0xF8; i++, ptr1++) {
762 762
             if (i >= q->bytes_per_frame)
763
-                return -1;
763
+                return AVERROR_INVALIDDATA;
764 764
         }
765 765
 
766 766
 
... ...
@@ -858,7 +858,7 @@ static int atrac3_decode_frame(AVCodecContext *avctx,
858 858
 
859 859
     if (result != 0) {
860 860
         av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n");
861
-        return -1;
861
+        return result;
862 862
     }
863 863
 
864 864
     /* interleave */
... ...
@@ -917,7 +917,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
917 917
         if ((q->bytes_per_frame == 96*q->channels*q->frame_factor) || (q->bytes_per_frame == 152*q->channels*q->frame_factor) || (q->bytes_per_frame == 192*q->channels*q->frame_factor)) {
918 918
         } else {
919 919
             av_log(avctx,AV_LOG_ERROR,"Unknown frame/channel/frame_factor configuration %d/%d/%d\n", q->bytes_per_frame, q->channels, q->frame_factor);
920
-            return -1;
920
+            return AVERROR_INVALIDDATA;
921 921
         }
922 922
 
923 923
     } else if (avctx->extradata_size == 10) {
... ...
@@ -937,17 +937,17 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
937 937
 
938 938
     if (q->atrac3version != 4) {
939 939
         av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version);
940
-        return -1;
940
+        return AVERROR_INVALIDDATA;
941 941
     }
942 942
 
943 943
     if (q->samples_per_frame != SAMPLES_PER_FRAME && q->samples_per_frame != SAMPLES_PER_FRAME*2) {
944 944
         av_log(avctx,AV_LOG_ERROR,"Unknown amount of samples per frame %d.\n",q->samples_per_frame);
945
-        return -1;
945
+        return AVERROR_INVALIDDATA;
946 946
     }
947 947
 
948 948
     if (q->delay != 0x88E) {
949 949
         av_log(avctx,AV_LOG_ERROR,"Unknown amount of delay %x != 0x88E.\n",q->delay);
950
-        return -1;
950
+        return AVERROR_INVALIDDATA;
951 951
     }
952 952
 
953 953
     if (q->codingMode == STEREO) {
... ...
@@ -956,17 +956,17 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx)
956 956
         av_log(avctx,AV_LOG_DEBUG,"Joint stereo detected.\n");
957 957
     } else {
958 958
         av_log(avctx,AV_LOG_ERROR,"Unknown channel coding mode %x!\n",q->codingMode);
959
-        return -1;
959
+        return AVERROR_INVALIDDATA;
960 960
     }
961 961
 
962 962
     if (avctx->channels <= 0 || avctx->channels > 2 /*|| ((avctx->channels * 1024) != q->samples_per_frame)*/) {
963 963
         av_log(avctx,AV_LOG_ERROR,"Channel configuration error!\n");
964
-        return -1;
964
+        return AVERROR(EINVAL);
965 965
     }
966 966
 
967 967
 
968 968
     if(avctx->block_align >= UINT_MAX/2)
969
-        return -1;
969
+        return AVERROR(EINVAL);
970 970
 
971 971
     /* Pad the data buffer with FF_INPUT_BUFFER_PADDING_SIZE,
972 972
      * this is for the bitstream reader. */