summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-01-11 20:40:51 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-01-11 20:40:51 +0000
commitb27ec53011b4c3ae0dabded53e435c3c4a3fe57a (patch)
treecb4be8102de64a4bc98cfda6cc9498ec75494974
parente8dded6d4fdec359fd8753c1893db2900d79dcb2 (diff)
downloadmpv-b27ec53011b4c3ae0dabded53e435c3c4a3fe57a.tar.bz2
mpv-b27ec53011b4c3ae0dabded53e435c3c4a3fe57a.tar.xz
Let the format filter do the AC3 endianness conversion instead of duplicating
the conversion code over and over. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30285 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--libaf/af_lavcac3enc.c28
-rw-r--r--libmpcodecs/ad_hwac3.c23
2 files changed, 14 insertions, 37 deletions
diff --git a/libaf/af_lavcac3enc.c b/libaf/af_lavcac3enc.c
index 1211453593..3d2d9e3b82 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 {
@@ -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_NE;
+ 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/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c
index afad9c615b..eb9dce072f 100644
--- a/libmpcodecs/ad_hwac3.c
+++ b/libmpcodecs/ad_hwac3.c
@@ -16,6 +16,7 @@
#include "help_mp.h"
#include "mpbswap.h"
#include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
#include "ad_internal.h"
@@ -151,7 +152,7 @@ static int preinit(sh_audio_t *sh)
sh->audio_in_minsize = 8192;
sh->channels = 2;
sh->samplesize = 2;
- sh->sample_format = AF_FORMAT_AC3_NE;
+ sh->sample_format = AF_FORMAT_AC3_BE;
return 1;
}
@@ -198,22 +199,12 @@ static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int m
}
else if(isdts == 0)
{
- uint16_t *buf16 = (uint16_t *)buf;
- buf16[0] = 0xF872; // iec 61937 syncword 1
- buf16[1] = 0x4E1F; // iec 61937 syncword 2
- buf16[2] = 0x0001; // data-type ac3
- buf16[2] |= (sh_audio->a_in_buffer[5] & 0x7) << 8; // bsmod
- buf16[3] = len << 3; // number of bits in payload
-#if HAVE_BIGENDIAN
+ AV_WB16(buf, 0xF872); // iec 61937 syncword 1
+ AV_WB16(buf + 2, 0x4E1F); // iec 61937 syncword 2
+ buf[4] = sh_audio->a_in_buffer[5] & 0x7; // bsmod
+ buf[5] = 0x01; // data-type ac3
+ AV_WB16(buf + 6, len << 3); // number of bits in payload
memcpy(buf + 8, sh_audio->a_in_buffer, len);
-#else
- swab(sh_audio->a_in_buffer, buf + 8, len);
- if (len & 1) {
- buf[8+len-1] = 0;
- buf[8+len] = sh_audio->a_in_buffer[len-1];
- len++;
- }
-#endif
memset(buf + 8 + len, 0, 6144 - 8 - len);
return 6144;