Commit afc0a24d authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  avcodec: add support for planar signed 8-bit PCM.
  ra144enc: add sample_fmts list to ff_ra_144_encoder
  smackaud: use uint8_t* for 8-bit output buffer type
  smackaud: clip output samples
  smackaud: use sign_extend() for difference value instead of casting
  sipr: use a function pointer to select the decode_frame function
  sipr: set mode based on block_align instead of bit_rate
  sipr: do not needlessly set *data_size to 0 when returning an error
  ra288: fix formatting of LOCAL_ALIGNED_16
  udp: Allow specifying the local IP address
  VC1: Add bottom field offset to block_index[] to avoid rewriting (+10L)
  vc1dec: move an if() block.
  vc1dec: use correct hybrid prediction threshold.
  vc1dec: Partial rewrite of vc1_pred_mv()
  vc1dec: take ME precision into account while scaling MV predictors.
  lavf: don't leak corrupted packets

Conflicts:
	libavcodec/8svx.c
	libavcodec/ra288.c
	libavcodec/version.h
	libavformat/iff.c
	libavformat/udp.c
	libavformat/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents dec354ba f1f6d361
......@@ -446,6 +446,11 @@ set the UDP buffer size in bytes
@item localport=@var{port}
override the local UDP port to bind with
@item localaddr=@var{addr}
Choose the local IP address. This is useful e.g. if sending multicast
and the host has multiple interfaces, where the user can choose
which interface to send on by specifying the IP address of that interface.
@item pkt_size=@var{size}
set the size in bytes of UDP packets
......
......@@ -110,7 +110,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data, int *data_si
if (!esc->samples && avpkt) {
uint8_t *deinterleaved_samples;
esc->samples_size = avctx->codec->id == CODEC_ID_8SVX_RAW ?
esc->samples_size = avctx->codec->id == CODEC_ID_8SVX_RAW || avctx->codec->id ==CODEC_ID_PCM_S8_PLANAR?
avpkt->size : avctx->channels + (avpkt->size-avctx->channels) * 2;
if (!(esc->samples = av_malloc(esc->samples_size)))
return AVERROR(ENOMEM);
......@@ -168,7 +168,7 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
{
EightSvxContext *esc = avctx->priv_data;
if (avctx->channels > 2) {
if (avctx->channels < 1 || avctx->channels > 2) {
av_log(avctx, AV_LOG_ERROR, "8SVX does not support more than 2 channels\n");
return AVERROR_INVALIDDATA;
}
......@@ -176,6 +176,7 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
switch (avctx->codec->id) {
case CODEC_ID_8SVX_FIB: esc->table = fibonacci; break;
case CODEC_ID_8SVX_EXP: esc->table = exponential; break;
case CODEC_ID_PCM_S8_PLANAR:
case CODEC_ID_8SVX_RAW: esc->table = NULL; break;
default:
av_log(avctx, AV_LOG_ERROR, "Invalid codec id %d.\n", avctx->codec->id);
......@@ -219,13 +220,13 @@ AVCodec ff_eightsvx_exp_decoder = {
.long_name = NULL_IF_CONFIG_SMALL("8SVX exponential"),
};
AVCodec ff_eightsvx_raw_decoder = {
.name = "8svx_raw",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_8SVX_RAW,
.priv_data_size = sizeof(EightSvxContext),
.init = eightsvx_decode_init,
.decode = eightsvx_decode_frame,
.close = eightsvx_decode_close,
.long_name = NULL_IF_CONFIG_SMALL("8SVX rawaudio"),
AVCodec ff_pcm_s8_planar_decoder = {
.name = "pcm_s8_planar",
.type = AVMEDIA_TYPE_AUDIO,
.id = CODEC_ID_PCM_S8_PLANAR,
.priv_data_size = sizeof(EightSvxContext),
.init = eightsvx_decode_init,
.close = eightsvx_decode_close,
.decode = eightsvx_decode_frame,
.long_name = NULL_IF_CONFIG_SMALL("PCM signed 8-bit planar"),
};
......@@ -485,6 +485,7 @@ OBJS-$(CONFIG_PCM_MULAW_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S8_PLANAR_DECODER) += 8svx.o
OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o
OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o
OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o
......
......@@ -107,7 +107,6 @@ void avcodec_register_all(void)
REGISTER_DECODER (EIGHTBPS, eightbps);
REGISTER_DECODER (EIGHTSVX_EXP, eightsvx_exp);
REGISTER_DECODER (EIGHTSVX_FIB, eightsvx_fib);
REGISTER_DECODER (EIGHTSVX_RAW, eightsvx_raw);
REGISTER_DECODER (ESCAPE124, escape124);
REGISTER_ENCDEC (FFV1, ffv1);
REGISTER_ENCDEC (FFVHUFF, ffvhuff);
......@@ -318,6 +317,7 @@ void avcodec_register_all(void)
REGISTER_DECODER (PCM_LXF, pcm_lxf);
REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw);
REGISTER_ENCDEC (PCM_S8, pcm_s8);
REGISTER_DECODER (PCM_S8_PLANAR, pcm_s8_planar);
REGISTER_ENCDEC (PCM_S16BE, pcm_s16be);
REGISTER_ENCDEC (PCM_S16LE, pcm_s16le);
REGISTER_DECODER (PCM_S16LE_PLANAR, pcm_s16le_planar);
......
......@@ -254,6 +254,7 @@ enum CodecID {
CODEC_ID_PCM_BLURAY,
CODEC_ID_PCM_LXF,
CODEC_ID_S302M,
CODEC_ID_PCM_S8_PLANAR,
/* various ADPCM codecs */
CODEC_ID_ADPCM_IMA_QT = 0x11000,
......
......@@ -516,5 +516,7 @@ AVCodec ff_ra_144_encoder = {
.init = ra144_encode_init,
.encode = ra144_encode_frame,
.close = ra144_encode_close,
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
AV_SAMPLE_FMT_NONE },
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K) encoder"),
};
......@@ -129,8 +129,8 @@ static void do_hybrid_window(RA288Context *ractx,
float buffer1[MAX_BACKWARD_FILTER_ORDER + 1];
float buffer2[MAX_BACKWARD_FILTER_ORDER + 1];
LOCAL_ALIGNED_16(float, work, [FFALIGN(MAX_BACKWARD_FILTER_ORDER +
MAX_BACKWARD_FILTER_LEN +
MAX_BACKWARD_FILTER_NONREC, 8)]);
MAX_BACKWARD_FILTER_LEN +
MAX_BACKWARD_FILTER_NONREC, 8)]);
ractx->dsp.vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 8));
......
......@@ -480,15 +480,24 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx)
SiprContext *ctx = avctx->priv_data;
int i;
if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
else ctx->mode = MODE_5k0;
switch (avctx->block_align) {
case 20: ctx->mode = MODE_16k; break;
case 19: ctx->mode = MODE_8k5; break;
case 29: ctx->mode = MODE_6k5; break;
case 37: ctx->mode = MODE_5k0; break;
default:
av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", avctx->block_align);
return AVERROR(EINVAL);
}
av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
if (ctx->mode == MODE_16k)
if (ctx->mode == MODE_16k) {
ff_sipr_init_16k(ctx);
ctx->decode_frame = ff_sipr_decode_frame_16k;
} else {
ctx->decode_frame = decode_frame;
}
for (i = 0; i < LP_FILTER_ORDER; i++)
ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1));
......@@ -518,8 +527,6 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
av_log(avctx, AV_LOG_ERROR,
"Error processing packet: packet size (%d) too small\n",
avpkt->size);
*data_size = 0;
return -1;
}
......@@ -530,8 +537,6 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
av_log(avctx, AV_LOG_ERROR,
"Error processing packet: output buffer (%d) too small\n",
*data_size);
*data_size = 0;
return -1;
}
......@@ -540,10 +545,7 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap,
for (i = 0; i < mode_par->frames_per_packet; i++) {
decode_parameters(&parm, &gb, mode_par);
if (ctx->mode == MODE_16k)
ff_sipr_decode_frame_16k(ctx, &parm, data);
else
decode_frame(ctx, &parm, data);
ctx->decode_frame(ctx, &parm, data);
data += subframe_size * mode_par->subframe_count;
}
......
......@@ -53,8 +53,18 @@ typedef enum {
MODE_COUNT
} SiprMode;
typedef struct {
typedef struct SiprParameters {
int ma_pred_switch; ///< switched moving average predictor
int vq_indexes[5];
int pitch_delay[5]; ///< pitch delay
int gp_index[5]; ///< adaptive-codebook gain indexes
int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
int gc_index[5]; ///< fixed-codebook gain indexes
} SiprParameters;
typedef struct SiprContext {
AVCodecContext *avctx;
AVFrame frame;
SiprMode mode;
......@@ -85,16 +95,10 @@ typedef struct {
float mem_preemph[LP_FILTER_ORDER_16k];
float synth[LP_FILTER_ORDER_16k];
double lsp_history_16k[16];
} SiprContext;
typedef struct {
int ma_pred_switch; ///< switched moving average predictor
int vq_indexes[5];
int pitch_delay[5]; ///< pitch delay
int gp_index[5]; ///< adaptive-codebook gain indexes
int16_t fc_indexes[5][10]; ///< fixed-codebook indexes
int gc_index[5]; ///< fixed-codebook gain indexes
} SiprParameters;
void (*decode_frame)(struct SiprContext *ctx, SiprParameters *params,
float *out_data);
} SiprContext;
extern const float ff_pow_0_5[16];
......
......@@ -33,6 +33,7 @@
#include "avcodec.h"
#include "libavutil/audioconvert.h"
#include "mathops.h"
#define ALT_BITSTREAM_READER_LE
#include "get_bits.h"
......@@ -580,7 +581,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
HuffContext h[4];
VLC vlc[4];
int16_t *samples = data;
int8_t *samples8 = data;
uint8_t *samples8 = data;
int val;
int i, res;
int unp_size;
......@@ -656,8 +657,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
else
res = 0;
val |= h[3].values[res] << 8;
pred[1] += (int16_t)val;
*samples++ = pred[1];
pred[1] += sign_extend(val, 16);
*samples++ = av_clip_int16(pred[1]);
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
......@@ -669,8 +670,8 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
else
res = 0;
val |= h[1].values[res] << 8;
pred[0] += val;
*samples++ = pred[0];
pred[0] += sign_extend(val, 16);
*samples++ = av_clip_int16(pred[0]);
}
}
} else { //8-bit data
......@@ -684,15 +685,15 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
res = get_vlc2(&gb, vlc[1].table, SMKTREE_BITS, 3);
else
res = 0;
pred[1] += (int8_t)h[1].values[res];
*samples8++ = pred[1];
pred[1] += sign_extend(h[1].values[res], 8);
*samples8++ = av_clip_uint8(pred[1]);
} else {
if(vlc[0].table)
res = get_vlc2(&gb, vlc[0].table, SMKTREE_BITS, 3);
else
res = 0;
pred[0] += (int8_t)h[0].values[res];
*samples8++ = pred[0];
pred[0] += sign_extend(h[0].values[res], 8);
*samples8++ = av_clip_uint8(pred[0]);
}
}
}
......
This diff is collapsed.
......@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 29
#define LIBAVCODEC_VERSION_MINOR 30
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
......@@ -239,7 +239,7 @@ static int iff_read_header(AVFormatContext *s,
switch (iff->svx8_compression) {
case COMP_NONE:
st->codec->codec_id = CODEC_ID_8SVX_RAW;
st->codec->codec_id = CODEC_ID_PCM_S8_PLANAR;
break;
case COMP_FIB:
st->codec->codec_id = CODEC_ID_8SVX_FIB;
......
......@@ -31,6 +31,7 @@
#include "libavutil/parseutils.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/avstring.h"
#include <unistd.h>
#include "internal.h"
#include "network.h"
......@@ -195,8 +196,8 @@ static int udp_set_url(struct sockaddr_storage *addr,
return addr_len;
}
static int udp_socket_create(UDPContext *s,
struct sockaddr_storage *addr, int *addr_len)
static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr,
int *addr_len, const char *localaddr)
{
int udp_fd = -1;
struct addrinfo *res0 = NULL, *res = NULL;
......@@ -204,7 +205,8 @@ static int udp_socket_create(UDPContext *s,
if (((struct sockaddr *) &s->dest_addr)->sa_family)
family = ((struct sockaddr *) &s->dest_addr)->sa_family;
res0 = udp_resolve_host(0, s->local_port, SOCK_DGRAM, family, AI_PASSIVE);
res0 = udp_resolve_host(localaddr[0] ? localaddr : NULL, s->local_port,
SOCK_DGRAM, family, AI_PASSIVE);
if (res0 == 0)
goto fail;
for (res = res0; res; res=res->ai_next) {
......@@ -377,7 +379,7 @@ static void *circular_buffer_task( void *_URLContext)
/* return non zero if error */
static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024];
char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = NULL;
int is_output;
......@@ -430,6 +432,9 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
}
if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
av_strlcpy(localaddr, buf, sizeof(localaddr));
}
}
/* fill the dest addr */
......@@ -447,7 +452,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
udp_fd = udp_socket_create(s, &my_addr, &len);
udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment