Permalink
Browse files

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  avcodec: remove AVCodecContext.dsp_mask
  avconv: fix a segfault when default encoder for a format doesn't exist.
  utvideo: general cosmetics
  aac: Handle HE-AACv2 when sniffing a channel order.
  movenc: Support high sample rates in isomedia formats by setting the sample rate field in stsd to 0.
  xxan: Remove write-only variable in xan_decode_frame_type0().
  ivi_common: Initialize a variable at declaration in ff_ivi_decode_blocks().

Conflicts:
	ffmpeg.c
	libavcodec/utvideo.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information...
michaelni committed Apr 21, 2012
2 parents 2f06b56 + 95510be commit c047afb80c7373c8533f5aeff6413015a814faaf
View
@@ -3014,6 +3014,7 @@ static int transcode_init(void)
if (!ost->enc)
ost->enc = avcodec_find_encoder(codec->codec_id);
if (!ost->enc) {
+ /* should only happen when a default codec is not present. */
snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d",
avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index);
ret = AVERROR(EINVAL);
View
@@ -410,6 +410,13 @@ static int output_configure(AACContext *ac,
if (ret < 0)
return ret;
}
+ if (ac->oc[1].m4ac.ps == 1 && channels == 2) {
+ if (layout == AV_CH_FRONT_CENTER) {
+ layout = AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT;
+ } else {
+ layout = 0;
+ }
+ }
memcpy(ac->tag_che_map, ac->che, 4 * MAX_ELEM_ID * sizeof(ac->che[0][0]));
if (layout) avctx->channel_layout = layout;
View
@@ -2622,15 +2622,13 @@ typedef struct AVCodecContext {
#define FF_IDCT_SIMPLEALPHA 23
#define FF_IDCT_BINK 24
+#if FF_API_DSP_MASK
/**
- * dsp_mask could be add used to disable unwanted CPU features
- * CPU features (i.e. MMX, SSE. ...)
- *
- * With the FORCE flag you may instead enable given CPU features.
- * (Dangerous: Usable in case of misdetection, improper usage however will
- * result into program crash.)
+ * Unused.
+ * @deprecated use av_set_cpu_flags_mask() instead.
*/
- unsigned dsp_mask;
+ attribute_deprecated unsigned dsp_mask;
+#endif
/**
* bits per sample/pixel from the demuxer (needed for huffyuv).
View
@@ -333,7 +333,7 @@ int ff_ivi_dec_tile_data_size(GetBitContext *gb)
int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
{
int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val,
- pos, is_intra, mc_type, mv_x, mv_y, col_mask;
+ pos, is_intra, mc_type = 0, mv_x, mv_y, col_mask;
uint8_t col_flags[8];
int32_t prev_dc, trvec[64];
uint32_t cbp, sym, lo, hi, quant, buf_offs, q;
@@ -373,9 +373,7 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
if (!is_intra) {
mv_x = mb->mv_x;
mv_y = mb->mv_y;
- if (!band->is_halfpel) {
- mc_type = 0; /* we have only fullpel vectors */
- } else {
+ if (band->is_halfpel) {
mc_type = ((mv_y & 1) << 1) | (mv_x & 1);
mv_x >>= 1;
mv_y >>= 1; /* convert halfpel vectors into fullpel ones */
View
@@ -467,7 +467,6 @@ static int update_context_from_user(AVCodecContext *dst, AVCodecContext *src)
dst->release_buffer = src->release_buffer;
dst->opaque = src->opaque;
- dst->dsp_mask = src->dsp_mask;
dst->debug = src->debug;
dst->debug_mv = src->debug_mv;
View
@@ -175,17 +175,19 @@ static int decode_plane(UtvideoContext *c, int plane_no,
continue;
}
- memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, slice_size);
+ memcpy(c->slice_bits, src + slice_data_start + c->slices * 4,
+ slice_size);
memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
- c->dsp.bswap_buf((uint32_t*)c->slice_bits, (uint32_t*)c->slice_bits,
+ c->dsp.bswap_buf((uint32_t *) c->slice_bits, (uint32_t *) c->slice_bits,
(slice_data_end - slice_data_start + 3) >> 2);
init_get_bits(&gb, c->slice_bits, slice_size * 8);
prev = 0x80;
for (j = sstart; j < send; j++) {
for (i = 0; i < width * step; i += step) {
if (get_bits_left(&gb) <= 0) {
- av_log(c->avctx, AV_LOG_ERROR, "Slice decoding ran out of bits\n");
+ av_log(c->avctx, AV_LOG_ERROR,
+ "Slice decoding ran out of bits\n");
goto fail;
}
pix = get_vlc2(&gb, vlc.table, vlc.bits, 4);
@@ -202,8 +204,8 @@ static int decode_plane(UtvideoContext *c, int plane_no,
dest += stride;
}
if (get_bits_left(&gb) > 32)
- av_log(c->avctx, AV_LOG_WARNING, "%d bits left after decoding slice\n",
- get_bits_left(&gb));
+ av_log(c->avctx, AV_LOG_WARNING,
+ "%d bits left after decoding slice\n", get_bits_left(&gb));
}
ff_free_vlc(&vlc);
@@ -216,7 +218,8 @@ static int decode_plane(UtvideoContext *c, int plane_no,
static const int rgb_order[4] = { 1, 2, 0, 3 };
-static void restore_rgb_planes(uint8_t *src, int step, int stride, int width, int height)
+static void restore_rgb_planes(uint8_t *src, int step, int stride, int width,
+ int height)
{
int i, j;
uint8_t r, g, b;
@@ -243,8 +246,9 @@ static void restore_median(uint8_t *src, int step, int stride,
const int cmask = ~rmode;
for (slice = 0; slice < slices; slice++) {
- slice_start = ((slice * height) / slices) & cmask;
- slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start;
+ slice_start = ((slice * height) / slices) & cmask;
+ slice_height = ((((slice + 1) * height) / slices) & cmask) -
+ slice_start;
bsrc = src + slice_start * stride;
@@ -253,29 +257,29 @@ static void restore_median(uint8_t *src, int step, int stride,
A = bsrc[0];
for (i = step; i < width * step; i += step) {
bsrc[i] += A;
- A = bsrc[i];
+ A = bsrc[i];
}
bsrc += stride;
if (slice_height == 1)
continue;
- // second line - first element has top predition, the rest uses median
- C = bsrc[-stride];
+ // second line - first element has top prediction, the rest uses median
+ C = bsrc[-stride];
bsrc[0] += C;
- A = bsrc[0];
+ A = bsrc[0];
for (i = step; i < width * step; i += step) {
- B = bsrc[i - stride];
+ B = bsrc[i - stride];
bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
- C = B;
- A = bsrc[i];
+ C = B;
+ A = bsrc[i];
}
bsrc += stride;
// the rest of lines use continuous median prediction
for (j = 2; j < slice_height; j++) {
for (i = 0; i < width * step; i += step) {
- B = bsrc[i - stride];
+ B = bsrc[i - stride];
bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
- C = B;
- A = bsrc[i];
+ C = B;
+ A = bsrc[i];
}
bsrc += stride;
}
@@ -293,67 +297,69 @@ static void restore_median_il(uint8_t *src, int step, int stride,
int A, B, C;
uint8_t *bsrc;
int slice_start, slice_height;
- const int cmask = ~(rmode ? 3 : 1);
+ const int cmask = ~(rmode ? 3 : 1);
const int stride2 = stride << 1;
for (slice = 0; slice < slices; slice++) {
slice_start = ((slice * height) / slices) & cmask;
- slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start;
+ slice_height = ((((slice + 1) * height) / slices) & cmask) -
+ slice_start;
slice_height >>= 1;
bsrc = src + slice_start * stride;
// first line - left neighbour prediction
bsrc[0] += 0x80;
- A = bsrc[0];
+ A = bsrc[0];
for (i = step; i < width * step; i += step) {
bsrc[i] += A;
- A = bsrc[i];
+ A = bsrc[i];
}
for (i = 0; i < width * step; i += step) {
bsrc[stride + i] += A;
- A = bsrc[stride + i];
+ A = bsrc[stride + i];
}
bsrc += stride2;
if (slice_height == 1)
continue;
- // second line - first element has top predition, the rest uses median
- C = bsrc[-stride2];
+ // second line - first element has top prediction, the rest uses median
+ C = bsrc[-stride2];
bsrc[0] += C;
- A = bsrc[0];
+ A = bsrc[0];
for (i = step; i < width * step; i += step) {
- B = bsrc[i - stride2];
+ B = bsrc[i - stride2];
bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
- C = B;
- A = bsrc[i];
+ C = B;
+ A = bsrc[i];
}
for (i = 0; i < width * step; i += step) {
- B = bsrc[i - stride];
+ B = bsrc[i - stride];
bsrc[stride + i] += mid_pred(A, B, (uint8_t)(A + B - C));
- C = B;
- A = bsrc[stride + i];
+ C = B;
+ A = bsrc[stride + i];
}
bsrc += stride2;
// the rest of lines use continuous median prediction
for (j = 2; j < slice_height; j++) {
for (i = 0; i < width * step; i += step) {
- B = bsrc[i - stride2];
+ B = bsrc[i - stride2];
bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C));
- C = B;
- A = bsrc[i];
+ C = B;
+ A = bsrc[i];
}
for (i = 0; i < width * step; i += step) {
- B = bsrc[i - stride];
+ B = bsrc[i - stride];
bsrc[i + stride] += mid_pred(A, B, (uint8_t)(A + B - C));
- C = B;
- A = bsrc[i + stride];
+ C = B;
+ A = bsrc[i + stride];
}
bsrc += stride2;
}
}
}
-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt)
+static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+ AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
@@ -374,7 +380,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
return ret;
}
- /* parse plane structure to retrieve frame flags and validate slice offsets */
+ /* parse plane structure to get frame flags and validate slice offsets */
bytestream2_init(&gb, buf, buf_size);
for (i = 0; i < c->planes; i++) {
plane_start[i] = gb.buffer;
@@ -441,8 +447,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
break;
case PIX_FMT_YUV420P:
for (i = 0; i < 3; i++) {
- ret = decode_plane(c, i, c->pic.data[i], 1,
- c->pic.linesize[i], avctx->width >> !!i, avctx->height >> !!i,
+ ret = decode_plane(c, i, c->pic.data[i], 1, c->pic.linesize[i],
+ avctx->width >> !!i, avctx->height >> !!i,
plane_start[i], c->frame_pred == PRED_LEFT);
if (ret)
return ret;
@@ -462,8 +468,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
break;
case PIX_FMT_YUV422P:
for (i = 0; i < 3; i++) {
- ret = decode_plane(c, i, c->pic.data[i], 1,
- c->pic.linesize[i], avctx->width >> !!i, avctx->height,
+ ret = decode_plane(c, i, c->pic.data[i], 1, c->pic.linesize[i],
+ avctx->width >> !!i, avctx->height,
plane_start[i], c->frame_pred == PRED_LEFT);
if (ret)
return ret;
@@ -500,15 +506,17 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_dsputil_init(&c->dsp, avctx);
if (avctx->extradata_size < 16) {
- av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d, should be at least 16\n",
+ av_log(avctx, AV_LOG_ERROR,
+ "Insufficient extradata size %d, should be at least 16\n",
avctx->extradata_size);
return AVERROR_INVALIDDATA;
}
av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d.%d.%d\n",
avctx->extradata[3], avctx->extradata[2],
avctx->extradata[1], avctx->extradata[0]);
- av_log(avctx, AV_LOG_DEBUG, "Original format %X\n", AV_RB32(avctx->extradata + 4));
+ av_log(avctx, AV_LOG_DEBUG, "Original format %X\n",
+ AV_RB32(avctx->extradata + 4));
c->frame_info_size = AV_RL32(avctx->extradata + 8);
c->flags = AV_RL32(avctx->extradata + 12);
View
@@ -78,5 +78,8 @@
#ifndef FF_API_SUB_ID
#define FF_API_SUB_ID (LIBAVCODEC_VERSION_MAJOR < 55)
#endif
+#ifndef FF_API_DSP_MASK
+#define FF_API_DSP_MASK (LIBAVCODEC_VERSION_MAJOR < 55)
+#endif
#endif /* AVCODEC_VERSION_H */
@@ -3185,13 +3185,6 @@ void ff_dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx)
{
int mm_flags = av_get_cpu_flags();
- if (avctx->dsp_mask) {
- if (avctx->dsp_mask & AV_CPU_FLAG_FORCE)
- mm_flags |= avctx->dsp_mask & 0xffff;
- else
- mm_flags &= ~(avctx->dsp_mask & 0xffff);
- }
-
#if 0
av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
if (mm_flags & AV_CPU_FLAG_MMX)
View
@@ -661,7 +661,8 @@ static int mov_write_audio_tag(AVIOContext *pb, MOVTrack *track)
}
avio_wb16(pb, 0); /* packet size (= 0) */
- avio_wb16(pb, track->enc->sample_rate);
+ avio_wb16(pb, track->enc->sample_rate <= UINT16_MAX ?
+ track->enc->sample_rate : 0);
avio_wb16(pb, 0); /* Reserved */
}
@@ -3199,17 +3200,11 @@ static int mov_write_header(AVFormatContext *s)
}else{
track->sample_size = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
}
- if (track->mode != MODE_MOV) {
- if (track->timescale > UINT16_MAX) {
- av_log(s, AV_LOG_ERROR, "track %d: output format does not support "
- "sample rate %dhz\n", i, track->timescale);
- goto error;
- }
- if (track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) {
- av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n",
- i, track->enc->sample_rate);
- goto error;
- }
+ if (track->mode != MODE_MOV &&
+ track->enc->codec_id == CODEC_ID_MP3 && track->timescale < 16000) {
+ av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n",
+ i, track->enc->sample_rate);
+ goto error;
}
}else if(st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE){
track->timescale = st->codec->time_base.den;

0 comments on commit c047afb

Please sign in to comment.