summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-07-21 02:49:57 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-07-21 04:25:11 +0200
commit3c033d00f5990e48b14f962d33c362f76695fb07 (patch)
tree261e11fc02302638fd451f9f0d3741fc444cc28c
parent85761efa95fd7cfb104fb862a242691d4e7c345c (diff)
parentce64e5bfd11ae63af0fb10317a2aea6f7501be62 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: libopenjpeg: introduce lowres and lowqual private options FATE: add a test for flac cover art. cafdec: allow larger ALAC magic cookie alac: fix channel pointer assignment for 24 and 32-bit Conflicts: libavcodec/alac.c libavcodec/libopenjpegdec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/alac.c8
-rw-r--r--libavcodec/libopenjpegdec.c22
-rw-r--r--libavformat/cafdec.c2
-rw-r--r--tests/fate/cover-art.mak4
4 files changed, 30 insertions, 6 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 83b2c1b247..f146238327 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -328,16 +328,16 @@ static int decode_element(AVCodecContext *avctx, void *data, int ch_index,
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- if (alac->direct_output) {
- for (ch = 0; ch < channels; ch++)
- alac->output_samples_buffer[ch] = (int32_t *)alac->frame.extended_data[ch_index + ch];
- }
} else if (output_samples != alac->nb_samples) {
av_log(avctx, AV_LOG_ERROR, "sample count mismatch: %u != %d\n",
output_samples, alac->nb_samples);
return AVERROR_INVALIDDATA;
}
alac->nb_samples = output_samples;
+ if (alac->direct_output) {
+ for (ch = 0; ch < channels; ch++)
+ alac->output_samples_buffer[ch] = (int32_t *)alac->frame.extended_data[ch_index + ch];
+ }
if (is_compressed) {
int16_t lpc_coefs[2][32];
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index 0643698653..fe4d86570e 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -24,6 +24,7 @@
* JPEG 2000 decoder using libopenjpeg
*/
+#include "libavutil/opt.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixfmt.h"
#include "avcodec.h"
@@ -54,8 +55,10 @@ static const enum PixelFormat libopenjpeg_yuv_pix_fmts[] = {YUV_PIXEL_FORMATS};
static const enum PixelFormat libopenjpeg_all_pix_fmts[] = {RGB_PIXEL_FORMATS,GRAY_PIXEL_FORMATS,YUV_PIXEL_FORMATS};
typedef struct {
+ AVClass *class;
opj_dparameters_t dec_params;
AVFrame image;
+ int lowqual;
} LibOpenJPEGContext;
static inline int libopenjpeg_matches_pix_fmt(const opj_image_t *image, enum PixelFormat pix_fmt){
@@ -254,8 +257,9 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
return -1;
}
opj_set_event_mgr((opj_common_ptr)dec, NULL, NULL);
-
ctx->dec_params.cp_limit_decoding = LIMIT_TO_MAIN_HEADER;
+ ctx->dec_params.cp_reduce = avctx->lowres;
+ ctx->dec_params.cp_layer = ctx->lowqual;
// Tie decoder with decoding parameters
opj_setup_decoder(dec, &ctx->dec_params);
stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
@@ -275,6 +279,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
}
width = image->x1 - image->x0;
height = image->y1 - image->y0;
+
if(av_image_check_size(width, height, 0, avctx) < 0) {
av_log(avctx, AV_LOG_ERROR, "%dx%d dimension invalid.\n", width, height);
goto done;
@@ -380,6 +385,20 @@ static av_cold int libopenjpeg_decode_close(AVCodecContext *avctx)
return 0 ;
}
+#define OFFSET(x) offsetof(LibOpenJPEGContext, x)
+#define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
+
+static const AVOption options[] = {
+ { "lowqual", "Limit the number of layers used for decoding", OFFSET(lowqual), AV_OPT_TYPE_INT, { 0 }, 0, INT_MAX, VD },
+ { NULL },
+};
+
+static const AVClass class = {
+ .class_name = "libopenjpeg",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
AVCodec ff_libopenjpeg_decoder = {
.name = "libopenjpeg",
@@ -392,5 +411,6 @@ AVCodec ff_libopenjpeg_decoder = {
.capabilities = CODEC_CAP_DR1 | CODEC_CAP_FRAME_THREADS,
.max_lowres = 5,
.long_name = NULL_IF_CONFIG_SMALL("OpenJPEG JPEG 2000"),
+ .priv_class = &class,
.init_thread_copy = ONLY_IF_THREADS_ENABLED(libopenjpeg_decode_init_thread_copy),
};
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c
index 0dacf2c4f1..15b3a8ffcf 100644
--- a/libavformat/cafdec.c
+++ b/libavformat/cafdec.c
@@ -124,7 +124,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
#define ALAC_HEADER 36
#define ALAC_NEW_KUKI 24
uint8_t preamble[12];
- if (size < ALAC_NEW_KUKI || size > ALAC_PREAMBLE + ALAC_HEADER) {
+ if (size < ALAC_NEW_KUKI) {
av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n");
avio_skip(pb, size);
return AVERROR_INVALIDDATA;
diff --git a/tests/fate/cover-art.mak b/tests/fate/cover-art.mak
index f35e9bb729..dadfcd8901 100644
--- a/tests/fate/cover-art.mak
+++ b/tests/fate/cover-art.mak
@@ -2,6 +2,10 @@ FATE_COVER_ART += fate-cover-art-ape
fate-cover-art-ape: CMD = md5 -i $(SAMPLES)/cover_art/luckynight_cover.ape -an -c:v copy -f rawvideo
fate-cover-art-ape: REF = 45333c983c45af54449dff10af144317
+FATE_COVER_ART += fate-cover-art-flac
+fate-cover-art-flac: CMD = md5 -i $(SAMPLES)/cover_art/cover_art.flac -an -c:v copy -f rawvideo
+fate-cover-art-flac: REF = 0de1fc6200596fa32b8f7300a14c0261
+
FATE_COVER_ART += fate-cover-art-m4a
fate-cover-art-m4a: CMD = md5 -i $(SAMPLES)/cover_art/Owner-iTunes_9.0.3.15.m4a -an -c:v copy -f rawvideo
fate-cover-art-m4a: REF = 08ba70a3b594ff6345a93965e96a9d3e