Browse code

qdm2: Return meaningful error codes

Himangi Saraogi authored on 2015/02/16 08:58:45
Showing 1 changed files
... ...
@@ -1762,7 +1762,7 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
1762 1762
 
1763 1763
     if (!avctx->extradata || (avctx->extradata_size < 48)) {
1764 1764
         av_log(avctx, AV_LOG_ERROR, "extradata missing or truncated\n");
1765
-        return -1;
1765
+        return AVERROR_INVALIDDATA;
1766 1766
     }
1767 1767
 
1768 1768
     extradata      = avctx->extradata;
... ...
@@ -1778,18 +1778,18 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
1778 1778
     if (extradata_size < 12) {
1779 1779
         av_log(avctx, AV_LOG_ERROR, "not enough extradata (%i)\n",
1780 1780
                extradata_size);
1781
-        return -1;
1781
+        return AVERROR_INVALIDDATA;
1782 1782
     }
1783 1783
 
1784 1784
     if (memcmp(extradata, "frmaQDM", 7)) {
1785 1785
         av_log(avctx, AV_LOG_ERROR, "invalid headers, QDM? not found\n");
1786
-        return -1;
1786
+        return AVERROR_INVALIDDATA;
1787 1787
     }
1788 1788
 
1789 1789
     if (extradata[7] == 'C') {
1790 1790
 //        s->is_qdmc = 1;
1791
-        av_log(avctx, AV_LOG_ERROR, "stream is QDMC version 1, which is not supported\n");
1792
-        return -1;
1791
+        avpriv_report_missing_feature(avctx, "QDMC version 1");
1792
+        return AVERROR_PATCHWELCOME;
1793 1793
     }
1794 1794
 
1795 1795
     extradata += 8;
... ...
@@ -1800,14 +1800,14 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
1800 1800
     if(size > extradata_size){
1801 1801
         av_log(avctx, AV_LOG_ERROR, "extradata size too small, %i < %i\n",
1802 1802
                extradata_size, size);
1803
-        return -1;
1803
+        return AVERROR_INVALIDDATA;
1804 1804
     }
1805 1805
 
1806 1806
     extradata += 4;
1807 1807
     av_log(avctx, AV_LOG_DEBUG, "size: %d\n", size);
1808 1808
     if (AV_RB32(extradata) != MKBETAG('Q','D','C','A')) {
1809 1809
         av_log(avctx, AV_LOG_ERROR, "invalid extradata, expecting QDCA\n");
1810
-        return -1;
1810
+        return AVERROR_INVALIDDATA;
1811 1811
     }
1812 1812
 
1813 1813
     extradata += 8;
... ...
@@ -1882,8 +1882,8 @@ static av_cold int qdm2_decode_init(AVCodecContext *avctx)
1882 1882
 
1883 1883
     // Fail on unknown fft order
1884 1884
     if ((s->fft_order < 7) || (s->fft_order > 9)) {
1885
-        av_log(avctx, AV_LOG_ERROR, "Unknown FFT order (%d), contact the developers!\n", s->fft_order);
1886
-        return -1;
1885
+        avpriv_request_sample(avctx, "Unknown FFT order %d", s->fft_order);
1886
+        return AVERROR_PATCHWELCOME;
1887 1887
     }
1888 1888
     if (s->fft_size != (1 << (s->fft_order - 1))) {
1889 1889
         av_log(avctx, AV_LOG_ERROR, "FFT size %d not power of 2.\n", s->fft_size);
... ...
@@ -1990,8 +1990,8 @@ static int qdm2_decode_frame(AVCodecContext *avctx, void *data,
1990 1990
     out = (int16_t *)frame->data[0];
1991 1991
 
1992 1992
     for (i = 0; i < 16; i++) {
1993
-        if (qdm2_decode(s, buf, out) < 0)
1994
-            return -1;
1993
+        if ((ret = qdm2_decode(s, buf, out)) < 0)
1994
+            return ret;
1995 1995
         out += s->channels * s->frame_size;
1996 1996
     }
1997 1997