Commit 15b86f48 authored by Jai Luthra's avatar Jai Luthra Committed by Rostislav Pehlivanov

mlpenc: Working MLP/TrueHD encoder

* Multichannel support for TrueHD is experimental

    There should be downmix substreams present for 2+ channel bitstreams,
    but ffmpeg decoder doesn't need it. Will add support for this soon.

* There might be lossless check failures on LFE channels

* 32-bit sample support has been removed for now, will add it later

    While testing, some samples gave lossless check failures when enforcing
    s32. Probably this will also get solved with the LFE issues.
Signed-off-by: 's avatarJai Luthra <me@jailuthra.in>
parent ee88dcb2
...@@ -383,6 +383,7 @@ OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o ...@@ -383,6 +383,7 @@ OBJS-$(CONFIG_MJPEG_ENCODER) += mjpegenc.o mjpegenc_common.o
OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o OBJS-$(CONFIG_MJPEGB_DECODER) += mjpegbdec.o
OBJS-$(CONFIG_MJPEG_VAAPI_ENCODER) += vaapi_encode_mjpeg.o OBJS-$(CONFIG_MJPEG_VAAPI_ENCODER) += vaapi_encode_mjpeg.o
OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o OBJS-$(CONFIG_MLP_DECODER) += mlpdec.o mlpdsp.o
OBJS-$(CONFIG_MLP_ENCODER) += mlpenc.o
OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o OBJS-$(CONFIG_MMVIDEO_DECODER) += mmvideo.o
OBJS-$(CONFIG_MOTIONPIXELS_DECODER) += motionpixels.o OBJS-$(CONFIG_MOTIONPIXELS_DECODER) += motionpixels.o
OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o OBJS-$(CONFIG_MOVTEXT_DECODER) += movtextdec.o ass.o
...@@ -546,6 +547,7 @@ OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o faxcompr.o tiff_data.o ti ...@@ -546,6 +547,7 @@ OBJS-$(CONFIG_TIFF_DECODER) += tiff.o lzw.o faxcompr.o tiff_data.o ti
OBJS-$(CONFIG_TIFF_ENCODER) += tiffenc.o rle.o lzwenc.o tiff_data.o OBJS-$(CONFIG_TIFF_ENCODER) += tiffenc.o rle.o lzwenc.o tiff_data.o
OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o OBJS-$(CONFIG_TMV_DECODER) += tmv.o cga_data.o
OBJS-$(CONFIG_TRUEHD_DECODER) += mlpdec.o mlpdsp.o OBJS-$(CONFIG_TRUEHD_DECODER) += mlpdec.o mlpdsp.o
OBJS-$(CONFIG_TRUEHD_ENCODER) += mlpenc.o
OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o OBJS-$(CONFIG_TRUEMOTION1_DECODER) += truemotion1.o
OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o OBJS-$(CONFIG_TRUEMOTION2_DECODER) += truemotion2.o
OBJS-$(CONFIG_TRUEMOTION2RT_DECODER) += truemotion2rt.o OBJS-$(CONFIG_TRUEMOTION2RT_DECODER) += truemotion2rt.o
......
...@@ -425,7 +425,7 @@ void avcodec_register_all(void) ...@@ -425,7 +425,7 @@ void avcodec_register_all(void)
REGISTER_DECODER(MACE3, mace3); REGISTER_DECODER(MACE3, mace3);
REGISTER_DECODER(MACE6, mace6); REGISTER_DECODER(MACE6, mace6);
REGISTER_DECODER(METASOUND, metasound); REGISTER_DECODER(METASOUND, metasound);
REGISTER_DECODER(MLP, mlp); REGISTER_ENCDEC (MLP, mlp);
REGISTER_DECODER(MP1, mp1); REGISTER_DECODER(MP1, mp1);
REGISTER_DECODER(MP1FLOAT, mp1float); REGISTER_DECODER(MP1FLOAT, mp1float);
REGISTER_ENCDEC (MP2, mp2); REGISTER_ENCDEC (MP2, mp2);
...@@ -454,7 +454,7 @@ void avcodec_register_all(void) ...@@ -454,7 +454,7 @@ void avcodec_register_all(void)
REGISTER_ENCDEC (SONIC, sonic); REGISTER_ENCDEC (SONIC, sonic);
REGISTER_ENCODER(SONIC_LS, sonic_ls); REGISTER_ENCODER(SONIC_LS, sonic_ls);
REGISTER_DECODER(TAK, tak); REGISTER_DECODER(TAK, tak);
REGISTER_DECODER(TRUEHD, truehd); REGISTER_ENCDEC (TRUEHD, truehd);
REGISTER_DECODER(TRUESPEECH, truespeech); REGISTER_DECODER(TRUESPEECH, truespeech);
REGISTER_ENCDEC (TTA, tta); REGISTER_ENCDEC (TTA, tta);
REGISTER_DECODER(TWINVQ, twinvq); REGISTER_DECODER(TWINVQ, twinvq);
......
...@@ -41,6 +41,27 @@ const uint8_t ff_mlp_huffman_tables[3][18][2] = { ...@@ -41,6 +41,27 @@ const uint8_t ff_mlp_huffman_tables[3][18][2] = {
} }
}; };
const ChannelInformation ff_mlp_ch_info[21] = {
{ 0x01, 0x01, 0x00, 0x1f }, { 0x03, 0x02, 0x00, 0x1b },
{ 0x07, 0x02, 0x01, 0x1f }, { 0x0F, 0x02, 0x02, 0x19 },
{ 0x07, 0x02, 0x01, 0x03 }, { 0x0F, 0x02, 0x02, 0x1f },
{ 0x1F, 0x02, 0x03, 0x01 }, { 0x07, 0x02, 0x01, 0x1a },
{ 0x0F, 0x02, 0x02, 0x1f }, { 0x1F, 0x02, 0x03, 0x18 },
{ 0x0F, 0x02, 0x02, 0x02 }, { 0x1F, 0x02, 0x03, 0x1f },
{ 0x3F, 0x02, 0x04, 0x00 }, { 0x0F, 0x03, 0x01, 0x1f },
{ 0x1F, 0x03, 0x02, 0x18 }, { 0x0F, 0x03, 0x01, 0x02 },
{ 0x1F, 0x03, 0x02, 0x1f }, { 0x3F, 0x03, 0x03, 0x00 },
{ 0x1F, 0x04, 0x01, 0x01 }, { 0x1F, 0x04, 0x01, 0x18 },
{ 0x3F, 0x04, 0x02, 0x00 },
};
const uint64_t ff_mlp_channel_layouts[12] = {
AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_2_1,
AV_CH_LAYOUT_QUAD, AV_CH_LAYOUT_2POINT1, AV_CH_LAYOUT_SURROUND,
AV_CH_LAYOUT_4POINT0, AV_CH_LAYOUT_5POINT0_BACK, AV_CH_LAYOUT_3POINT1,
AV_CH_LAYOUT_4POINT1, AV_CH_LAYOUT_5POINT1_BACK, 0,
};
static int crc_init = 0; static int crc_init = 0;
#if CONFIG_SMALL #if CONFIG_SMALL
#define CRC_TABLE_SIZE 257 #define CRC_TABLE_SIZE 257
......
...@@ -76,6 +76,9 @@ typedef struct FilterParams { ...@@ -76,6 +76,9 @@ typedef struct FilterParams {
uint8_t shift; ///< Right shift to apply to output of filter. uint8_t shift; ///< Right shift to apply to output of filter.
int32_t state[MAX_FIR_ORDER]; int32_t state[MAX_FIR_ORDER];
int coeff_bits;
int coeff_shift;
} FilterParams; } FilterParams;
/** sample data coding information */ /** sample data coding information */
...@@ -96,6 +99,43 @@ typedef struct ChannelParams { ...@@ -96,6 +99,43 @@ typedef struct ChannelParams {
*/ */
extern const uint8_t ff_mlp_huffman_tables[3][18][2]; extern const uint8_t ff_mlp_huffman_tables[3][18][2];
typedef struct {
uint8_t channel_occupancy;
uint8_t group1_channels;
uint8_t group2_channels;
uint8_t summary_info;
} ChannelInformation;
/** Tables defining channel information.
*
* Possible channel arrangements are:
*
* (Group 1) C
* (Group 1) L, R
* (Group 1) Lf, Rf / (Group 2) S
* (Group 1) Lf, Rf / (Group 2) Ls, Rs
* (Group 1) Lf, Rf / (Group 2) LFE
* (Group 1) Lf, Rf / (Group 2) LFE, S
* (Group 1) Lf, Rf / (Group 2) LFE, Ls, Rs
* (Group 1) Lf, Rf / (Group 2) C
* (Group 1) Lf, Rf / (Group 2) C, S
* (Group 1) Lf, Rf / (Group 2) C, Ls, Rs
* (Group 1) Lf, Rf / (Group 2) C, LFE
* (Group 1) Lf, Rf / (Group 2) C, LFE, S
* (Group 1) Lf, Rf / (Group 2) C, LFE, Ls, Rs
* (Group 1) Lf, Rf C / (Group 2) S
* (Group 1) Lf, Rf C / (Group 2) Ls, Rs
* (Group 1) Lf, Rf C / (Group 2) LFE
* (Group 1) Lf, Rf C / (Group 2) LFE, S
* (Group 1) Lf, Rf C / (Group 2) LFE, Ls, Rs
* (Group 1) Lf, Rf Ls Rs / (Group 2) LFE
* (Group 1) Lf, Rf Ls Rs / (Group 2) C
* (Group 1) Lf, Rf, Ls, Rs / (Group 2) C, LFE
*/
extern const ChannelInformation ff_mlp_ch_info[21];
extern const uint64_t ff_mlp_channel_layouts[12];
/** MLP uses checksums that seem to be based on the standard CRC algorithm, but /** MLP uses checksums that seem to be based on the standard CRC algorithm, but
* are not (in implementation terms, the table lookup and XOR are reversed). * are not (in implementation terms, the table lookup and XOR are reversed).
* We can implement this behavior using a standard av_crc on all but the * We can implement this behavior using a standard av_crc on all but the
......
This diff is collapsed.
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