diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-01-25 15:04:07 +0200 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-01-25 15:07:30 +0200 |
commit | 69fe2522f8c2a04eda112eee6319ca2e85d7038b (patch) | |
tree | 83a8b19997e621309344ca1f3997a48886ef0944 /libaf | |
parent | 9436e0452fad48e671d7320cb18c588655f3d230 (diff) | |
parent | 1cda8b002fb19c3da14760fe1f9fc76992a05c29 (diff) | |
download | mpv-69fe2522f8c2a04eda112eee6319ca2e85d7038b.tar.bz2 mpv-69fe2522f8c2a04eda112eee6319ca2e85d7038b.tar.xz |
Merge svn changes up to r30301
Diffstat (limited to 'libaf')
-rw-r--r-- | libaf/af_format.c | 4 | ||||
-rw-r--r-- | libaf/af_format.h | 9 | ||||
-rw-r--r-- | libaf/af_lavcac3enc.c | 30 | ||||
-rw-r--r-- | libaf/format.c | 7 |
4 files changed, 24 insertions, 26 deletions
diff --git a/libaf/af_format.c b/libaf/af_format.c index 64acbbb9b6..3b9b907882 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -98,6 +98,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg) af->data->bps == data->bps) return AF_DETACH; + // Allow trivial AC3-endianness conversion + if (!AF_FORMAT_IS_AC3(af->data->format) || !AF_FORMAT_IS_AC3(data->format)) // Check for errors in configuration if((AF_OK != check_bps(data->bps)) || (AF_OK != check_format(data->format)) || @@ -152,7 +154,7 @@ static int control(struct af_instance_s* af, int cmd, void* arg) } case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET:{ // Check for errors in configuration - if(AF_OK != check_format(*(int*)arg)) + if(!AF_FORMAT_IS_AC3(*(int*)arg) && AF_OK != check_format(*(int*)arg)) return AF_ERROR; af->data->format = *(int*)arg; diff --git a/libaf/af_format.h b/libaf/af_format.h index e5e5c1cb05..5f194c1365 100644 --- a/libaf/af_format.h +++ b/libaf/af_format.h @@ -59,7 +59,7 @@ #define AF_FORMAT_MU_LAW (1<<6) #define AF_FORMAT_A_LAW (2<<6) #define AF_FORMAT_MPEG2 (3<<6) // MPEG(2) audio -#define AF_FORMAT_AC3 ((4<<6)|AF_FORMAT_16BIT) // Dolby Digital AC3 +#define AF_FORMAT_AC3 (4<<6) // Dolby Digital AC3 #define AF_FORMAT_IMA_ADPCM (5<<6) #define AF_FORMAT_SPECIAL_MASK (7<<6) @@ -83,6 +83,9 @@ #define AF_FORMAT_FLOAT_LE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_LE) #define AF_FORMAT_FLOAT_BE (AF_FORMAT_F|AF_FORMAT_32BIT|AF_FORMAT_BE) +#define AF_FORMAT_AC3_LE (AF_FORMAT_AC3|AF_FORMAT_16BIT|AF_FORMAT_LE) +#define AF_FORMAT_AC3_BE (AF_FORMAT_AC3|AF_FORMAT_16BIT|AF_FORMAT_BE) + #if HAVE_BIGENDIAN #define AF_FORMAT_U16_NE AF_FORMAT_U16_BE #define AF_FORMAT_S16_NE AF_FORMAT_S16_BE @@ -91,6 +94,7 @@ #define AF_FORMAT_U32_NE AF_FORMAT_U32_BE #define AF_FORMAT_S32_NE AF_FORMAT_S32_BE #define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_BE +#define AF_FORMAT_AC3_NE AF_FORMAT_AC3_BE #else #define AF_FORMAT_U16_NE AF_FORMAT_U16_LE #define AF_FORMAT_S16_NE AF_FORMAT_S16_LE @@ -99,10 +103,13 @@ #define AF_FORMAT_U32_NE AF_FORMAT_U32_LE #define AF_FORMAT_S32_NE AF_FORMAT_S32_LE #define AF_FORMAT_FLOAT_NE AF_FORMAT_FLOAT_LE +#define AF_FORMAT_AC3_NE AF_FORMAT_AC3_LE #endif #define AF_FORMAT_UNKNOWN (-1) +#define AF_FORMAT_IS_AC3(fmt) (((fmt) & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_AC3) + int af_str2fmt(const char *str); int af_str2fmt_short(const char *str); int af_fmt2bits(int format); diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c index 628c397002..a86b7fbdbd 100644 --- a/libaf/af_lavcac3enc.c +++ b/libaf/af_lavcac3enc.c @@ -32,6 +32,7 @@ #include "libavcodec/avcodec.h" #include "libavcodec/ac3.h" +#include "libavutil/intreadwrite.h" // Data for specific instances of this filter typedef struct af_ac3enc_s { @@ -58,7 +59,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg) switch (cmd){ case AF_CONTROL_REINIT: - if (data->format == AF_FORMAT_AC3 || data->nch < s->min_channel_num) + if (AF_FORMAT_IS_AC3(data->format) || data->nch < s->min_channel_num) return AF_DETACH; s->pending_len = 0; @@ -102,7 +103,7 @@ static int control(struct af_instance_s *af, int cmd, void *arg) return AF_ERROR; } } - af->data->format = AF_FORMAT_AC3; + af->data->format = AF_FORMAT_AC3_BE; af->data->nch = 2; return test_output_res; case AF_CONTROL_COMMAND_LINE: @@ -235,28 +236,13 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) len, s->pending_len); if (s->add_iec61937_header) { - int16_t *out = (int16_t *)buf; int bsmod = dest[5] & 0x7; -#if !HAVE_BIGENDIAN - int i; - char tmp; - for (i = 0; i < len; i += 2) { - tmp = dest[i]; - dest[i] = dest[i+1]; - dest[i+1] = tmp; - } - if (len & 1) { - dest[len] = dest[len-1]; - dest[len-1] = 0; - len++; - } -#endif - out[0] = 0xF872; // iec 61937 syncword 1 - out[1] = 0x4E1F; // iec 61937 syncword 2 - out[2] = 0x0001; // data-type ac3 - out[2] |= bsmod << 8; // bsmod - out[3] = len << 3; // number of bits in payload + AV_WB16(buf, 0xF872); // iec 61937 syncword 1 + AV_WB16(buf + 2, 0x4E1F); // iec 61937 syncword 2 + buf[4] = bsmod; // bsmod + buf[5] = 0x01; // data-type ac3 + AV_WB16(buf + 6, len << 3); // number of bits in payload memset(buf + 8 + len, 0, AC3_FRAME_SIZE * 2 * 2 - 8 - len); len = AC3_FRAME_SIZE * 2 * 2; diff --git a/libaf/format.c b/libaf/format.c index 93dfdbbc31..8146899c7e 100644 --- a/libaf/format.c +++ b/libaf/format.c @@ -47,7 +47,7 @@ int af_str2fmt(const char* str) format |= AF_FORMAT_A_LAW; return format; } if(strstr(str,"ac3") || strstr(str,"AC3")){ - format |= AF_FORMAT_AC3; return format; + format |= AF_FORMAT_AC3 | AF_FORMAT_16BIT; return format; } if(strstr(str,"mpeg2") || strstr(str,"MPEG2")){ format |= AF_FORMAT_MPEG2; return format; @@ -74,6 +74,7 @@ int af_str2fmt(const char* str) int af_fmt2bits(int format) { + if (AF_FORMAT_IS_AC3(format)) return 16; return (format & AF_FORMAT_BITS_MASK)+8; // return (((format & AF_FORMAT_BITS_MASK)>>3)+1) * 8; #if 0 @@ -157,7 +158,9 @@ static struct { { "mulaw", AF_FORMAT_MU_LAW }, { "alaw", AF_FORMAT_A_LAW }, { "mpeg2", AF_FORMAT_MPEG2 }, - { "ac3", AF_FORMAT_AC3 }, + { "ac3le", AF_FORMAT_AC3_LE }, + { "ac3be", AF_FORMAT_AC3_BE }, + { "ac3ne", AF_FORMAT_AC3_NE }, { "imaadpcm", AF_FORMAT_IMA_ADPCM }, { "u8", AF_FORMAT_U8 }, |