[FFmpeg-devel] [PATCH 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2021-05-07 Thread Cameron Cawley
---
 Changelog |  1 +
 doc/general_contents.texi |  1 +
 libavcodec/Makefile   |  1 +
 libavcodec/adpcm.c| 19 +++
 libavcodec/allcodecs.c|  1 +
 libavcodec/codec_desc.c   |  7 +++
 libavcodec/codec_id.h |  1 +
 libavcodec/utils.c|  1 +
 libavcodec/version.h  |  2 +-
 9 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ad950354d0..c38c5d63a0 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - ADPCM IMA Westwood encoder
 - Westwood AUD muxer
+- ADPCM IMA Acorn Replay decoder
 
 
 version 4.4:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e01347f8d4..354899ad17 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1126,6 +1126,7 @@ following image formats are supported:
 @item ADPCM Electronic Arts XAS @tab @tab  X
 @item ADPCM G.722@tab  X  @tab  X
 @item ADPCM G.726@tab  X  @tab  X
+@item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab  X  @tab  X
 @tab Used in AMV files
 @item ADPCM IMA Cunning Developments  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 075b0ad7a3..4fa8d7ab10 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -868,6 +868,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_ENCODER)  += adpcmenc.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 3da6b734cf..8fe43b5720 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -747,6 +747,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 switch (avctx->codec->id) {
 case AV_CODEC_ID_ADPCM_4XM:
 case AV_CODEC_ID_ADPCM_AGM:
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
 case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;  break;
@@ -1665,6 +1666,23 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 }
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
+for (channel = 0; channel < avctx->channels; channel++) {
+cs = &c->status[channel];
+cs->predictor  = sign_extend(bytestream2_get_le16u(&gb), 16);
+cs->step_index = bytestream2_get_le16u(&gb) & 0xFF;
+if (cs->step_index > 88u){
+av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
+   channel, cs->step_index);
+return AVERROR_INVALIDDATA;
+}
+}
+for (n = nb_samples >> (1 - st); n > 0; n--) {
+int byte = bytestream2_get_byteu(&gb);
+*samples++ = adpcm_ima_expand_nibble(&c->status[0],  byte & 0x0F, 
3);
+*samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4,   
3);
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_AMV:
 av_assert0(avctx->channels == 1);
 
@@ -2160,6 +2178,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,   
sample_fmts_s16p, adpcm_ea_r1,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,   sample_fmts_s16p, adpcm_ea_r2,
   "ADPCM Electronic Arts R2");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,   sample_fmts_s16p, adpcm_ea_r3,
   "ADPCM Electronic Arts R3");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  sample_fmts_s16p, adpcm_ea_xas,   
   "ADPCM Electronic Arts XAS");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,  
adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,  adpcm_ima_amv,  
   "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,  adpcm_ima_apc,  
   "ADPCM IMA CRYO APC");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APM, sample_fmts_s16,  adpcm_ima_apm,  
   "ADPCM IMA Ubisoft APM");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 73dd3d0695..0b15b59364 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -619,6 +619,7 @@ extern const AVCodec ff_adpcm_g726_encoder;
 extern const AVCodec ff_adpcm_g726_decoder;
 extern const AVCodec ff_adpcm_g726le_encoder;
 extern const AVCodec ff_adpcm_g726le_decoder;
+extern const AVCodec ff_adpcm_ima_acorn_decoder;
 extern const AVCodec ff_adpcm_ima_amv_decoder;
 extern const AVCodec ff_adpcm_ima_amv_encoder;
 extern const AVCodec ff_adpcm_ima_alp_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 17f8a14044..35527dcc37 100644
--- a/libavcodec/codec_desc.c
+++ b/

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Support files containing Replay IMA ADPCM audio

2021-05-07 Thread Cameron Cawley
---
 libavformat/rpl.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 367e80b2c4..d495734e8e 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -121,6 +121,7 @@ static int rpl_read_header(AVFormatContext *s)
 int error = 0;
 const char *endptr;
 char audio_type[RPL_LINE_LENGTH];
+char audio_codec[RPL_LINE_LENGTH];
 
 uint32_t i;
 
@@ -189,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
 
 // ARMovie supports multiple audio tracks; I don't have any
 // samples, though. This code will ignore additional tracks.
-audio_format = read_line_and_int(pb, &error);  // audio format ID
+error |= read_line(pb, line, sizeof(line));
+audio_format = read_int(line, &endptr, &error);  // audio format ID
+av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
 if (audio_format) {
 ast = avformat_new_stream(s, NULL);
 if (!ast)
@@ -227,6 +230,11 @@ static int rpl_read_header(AVFormatContext *s)
 // There are some other formats listed as legal per the spec;
 // samples needed.
 break;
+case 2:
+if (av_stristr(audio_codec, "adpcm") != NULL) {
+ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+}
+break;
 case 101:
 if (ast->codecpar->bits_per_coded_sample == 8) {
 // The samples with this kind of audio that I have
@@ -238,8 +246,8 @@ static int rpl_read_header(AVFormatContext *s)
 break;
 }
 if (ast->codecpar->codec_id == AV_CODEC_ID_NONE)
-avpriv_request_sample(s, "Audio format %"PRId32,
-  audio_format);
+avpriv_request_sample(s, "Audio format %"PRId32" (%s)",
+  audio_format, audio_codec);
 avpriv_set_pts_info(ast, 32, 1, ast->codecpar->bit_rate);
 } else {
 for (i = 0; i < 3; i++)
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Support files containing Replay IMA ADPCM audio

2021-05-03 Thread Cameron Cawley
---
 libavformat/rpl.c | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index f5d2b8fe59..39e8235b48 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -121,6 +121,7 @@ static int rpl_read_header(AVFormatContext *s)
 int error = 0;
 const char *endptr;
 char audio_type[RPL_LINE_LENGTH];
+char audio_codec[RPL_LINE_LENGTH];
 
 uint32_t i;
 
@@ -189,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
 
 // ARMovie supports multiple audio tracks; I don't have any
 // samples, though. This code will ignore additional tracks.
-audio_format = read_line_and_int(pb, &error);  // audio format ID
+error |= read_line(pb, line, sizeof(line));
+audio_format = read_int(line, &endptr, &error);  // audio format ID
+av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
 if (audio_format) {
 ast = avformat_new_stream(s, NULL);
 if (!ast)
@@ -232,6 +235,12 @@ static int rpl_read_header(AVFormatContext *s)
 // There are some other formats listed as legal per the spec;
 // samples needed.
 break;
+case 2:
+   if(av_stristr(audio_codec, "adpcm") != NULL) {
+ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+break;
+}
+break;
 case 101:
 if (ast->codecpar->bits_per_coded_sample == 8) {
 // The samples with this kind of audio that I have
@@ -245,8 +254,8 @@ static int rpl_read_header(AVFormatContext *s)
 break;
 }
 if (ast->codecpar->codec_id == AV_CODEC_ID_NONE)
-avpriv_request_sample(s, "Audio format %"PRId32,
-  audio_format);
+avpriv_request_sample(s, "Audio format %"PRId32" (%s)",
+  audio_format, audio_codec);
 avpriv_set_pts_info(ast, 32, 1, ast->codecpar->bit_rate);
 } else {
 for (i = 0; i < 3; i++)
-- 
2.20.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2021-05-03 Thread Cameron Cawley
---
 Changelog |  1 +
 doc/general_contents.texi |  1 +
 libavcodec/Makefile   |  1 +
 libavcodec/adpcm.c| 19 +++
 libavcodec/allcodecs.c|  1 +
 libavcodec/codec_desc.c   |  7 +++
 libavcodec/codec_id.h |  1 +
 libavcodec/utils.c|  1 +
 libavcodec/version.h  |  2 +-
 9 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index ad950354d0..c38c5d63a0 100644
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.
 version :
 - ADPCM IMA Westwood encoder
 - Westwood AUD muxer
+- ADPCM IMA Acorn Replay decoder
 
 
 version 4.4:
diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index e01347f8d4..354899ad17 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -1126,6 +1126,7 @@ following image formats are supported:
 @item ADPCM Electronic Arts XAS @tab @tab  X
 @item ADPCM G.722@tab  X  @tab  X
 @item ADPCM G.726@tab  X  @tab  X
+@item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab  X  @tab  X
 @tab Used in AMV files
 @item ADPCM IMA Cunning Developments  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 075b0ad7a3..4fa8d7ab10 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -868,6 +868,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_ALP_ENCODER)  += adpcmenc.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 3da6b734cf..8fe43b5720 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -747,6 +747,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 switch (avctx->codec->id) {
 case AV_CODEC_ID_ADPCM_4XM:
 case AV_CODEC_ID_ADPCM_AGM:
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
 case AV_CODEC_ID_ADPCM_IMA_MOFLEX:
 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;  break;
@@ -1665,6 +1666,23 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 }
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
+for (channel = 0; channel < avctx->channels; channel++) {
+cs = &c->status[channel];
+cs->predictor  = sign_extend(bytestream2_get_le16u(&gb), 16);
+cs->step_index = bytestream2_get_le16u(&gb) & 0xFF;
+if (cs->step_index > 88u){
+av_log(avctx, AV_LOG_ERROR, "ERROR: step_index[%d] = %i\n",
+   channel, cs->step_index);
+return AVERROR_INVALIDDATA;
+}
+}
+for (n = nb_samples >> (1 - st); n > 0; n--) {
+int byte = bytestream2_get_byteu(&gb);
+*samples++ = adpcm_ima_expand_nibble(&c->status[0],  byte & 0x0F, 
3);
+*samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4,   
3);
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_AMV:
 av_assert0(avctx->channels == 1);
 
@@ -2160,6 +2178,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,   
sample_fmts_s16p, adpcm_ea_r1,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,   sample_fmts_s16p, adpcm_ea_r2,
   "ADPCM Electronic Arts R2");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,   sample_fmts_s16p, adpcm_ea_r3,
   "ADPCM Electronic Arts R3");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  sample_fmts_s16p, adpcm_ea_xas,   
   "ADPCM Electronic Arts XAS");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,  
adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,  adpcm_ima_amv,  
   "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,  adpcm_ima_apc,  
   "ADPCM IMA CRYO APC");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APM, sample_fmts_s16,  adpcm_ima_apm,  
   "ADPCM IMA Ubisoft APM");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 73dd3d0695..0b15b59364 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -619,6 +619,7 @@ extern const AVCodec ff_adpcm_g726_encoder;
 extern const AVCodec ff_adpcm_g726_decoder;
 extern const AVCodec ff_adpcm_g726le_encoder;
 extern const AVCodec ff_adpcm_g726le_decoder;
+extern const AVCodec ff_adpcm_ima_acorn_decoder;
 extern const AVCodec ff_adpcm_ima_amv_decoder;
 extern const AVCodec ff_adpcm_ima_amv_encoder;
 extern const AVCodec ff_adpcm_ima_alp_decoder;
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 17f8a14044..35527dcc37 100644
--- a/libavcodec/codec_desc.c
+++ b/

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Support files containing Replay IMA ADPCM audio

2019-08-08 Thread Cameron Cawley
---
 libavformat/rpl.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 6afd373810..d31c7f09ad 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -121,6 +121,7 @@ static int rpl_read_header(AVFormatContext *s)
 int error = 0;
 const char *endptr;
 char audio_type[RPL_LINE_LENGTH];
+char audio_codec[RPL_LINE_LENGTH];
 
 uint32_t i;
 
@@ -189,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
 
 // ARMovie supports multiple audio tracks; I don't have any
 // samples, though. This code will ignore additional tracks.
-audio_format = read_line_and_int(pb, &error);  // audio format ID
+error |= read_line(pb, line, sizeof(line));
+audio_format = read_int(line, &endptr, &error);  // audio format ID
+av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
 if (audio_format) {
 ast = avformat_new_stream(s, NULL);
 if (!ast)
@@ -229,6 +232,14 @@ static int rpl_read_header(AVFormatContext *s)
 break;
 }
 }
+break;
+case 2:
+if (av_strcasecmp(audio_codec," adpcm") == 0) {
+ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+} else {
+avpriv_report_missing_feature(s, "Audio format %"PRId32" 
(%s)",
+  audio_format, audio_codec);
+}
 // There are some other formats listed as legal per the spec;
 // samples needed.
 break;
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-08-08 Thread Cameron Cawley
Signed-off-by: Cameron Cawley 
---
 doc/general.texi|  1 +
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 14 ++
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/utils.c  |  1 +
 7 files changed, 26 insertions(+)

diff --git a/doc/general.texi b/doc/general.texi
index 3c0c803449..db30738716 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1072,6 +1072,7 @@ following image formats are supported:
 @item ADPCM Electronic Arts XAS @tab @tab  X
 @item ADPCM G.722@tab  X  @tab  X
 @item ADPCM G.726@tab  X  @tab  X
+@item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab @tab  X
 @tab Used in AMV files
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 3cd73fbcc6..c0a038495f 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -825,6 +825,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index fb126503d6..70503fc0b1 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -599,6 +599,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 switch (avctx->codec->id) {
 case AV_CODEC_ID_ADPCM_4XM:
 case AV_CODEC_ID_ADPCM_AGM:
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;  break;
 case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8;   break;
@@ -1441,6 +1442,18 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 }
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
+for (i=0; i<=st; i++) {
+bytestream2_skip(&gb, 2); // TODO: What does this do?
+c->status[i].step_index = bytestream2_get_le16u(&gb);
+}
+
+for (n = nb_samples >> (1 - st); n > 0; n--) {
+int byte = bytestream2_get_byteu(&gb);
+*samples++ = adpcm_ima_expand_nibble(&c->status[0],  byte & 0x0F, 
6);
+*samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4,   
6);
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_AMV:
 c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
 c->status[0].step_index = bytestream2_get_byteu(&gb);
@@ -1825,6 +1838,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,   
sample_fmts_s16p, adpcm_ea_r1,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,   sample_fmts_s16p, adpcm_ea_r2,
   "ADPCM Electronic Arts R2");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,   sample_fmts_s16p, adpcm_ea_r3,
   "ADPCM Electronic Arts R3");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  sample_fmts_s16p, adpcm_ea_xas,   
   "ADPCM Electronic Arts XAS");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,  
adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,  adpcm_ima_amv,  
   "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,  adpcm_ima_apc,  
   "ADPCM IMA CRYO APC");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4,sample_fmts_s16,  adpcm_ima_dat4, 
   "ADPCM IMA Eurocom DAT4");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39ce5..78177a1255 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -592,6 +592,7 @@ extern AVCodec ff_adpcm_g726_encoder;
 extern AVCodec ff_adpcm_g726_decoder;
 extern AVCodec ff_adpcm_g726le_encoder;
 extern AVCodec ff_adpcm_g726le_decoder;
+extern AVCodec ff_adpcm_ima_acorn_decoder;
 extern AVCodec ff_adpcm_ima_amv_decoder;
 extern AVCodec ff_adpcm_ima_apc_decoder;
 extern AVCodec ff_adpcm_ima_dat4_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index d234271c5b..c8b6ec7f3c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -542,6 +542,7 @@ enum AVCodecID {
 AV_CODEC_ID_ADPCM_IMA_DAT4,
 AV_CODEC_ID_ADPCM_MTAF,
 AV_CODEC_ID_ADPCM_AGM,
+AV_CODEC_ID_ADPCM_IMA_ACORN,
 
 /* AMR */
 AV_CODEC_ID_AMR_NB = 0x12000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 4d033c20ff..dc39b50e33 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2276,6 +2276,13 @@ static const AVCodecDescriptor c

Re: [FFmpeg-devel] [PATCH 1/2] avformat/rpl: Replace strcpy with av_strlcpy

2019-07-09 Thread Cameron Cawley
The second use of strcpy() that this patch fixes was added in
commit 0e9c01f.

Regards
Cameron

On Fri, 5 Jul 2019 at 17:47, Michael Niedermayer 
wrote:

> On Sun, Jun 30, 2019 at 12:00:43AM +0100, Cameron Cawley wrote:
> > ---
> >  libavformat/rpl.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavformat/rpl.c b/libavformat/rpl.c
> > index b4859320f4..579ab4f57e 100644
> > --- a/libavformat/rpl.c
> > +++ b/libavformat/rpl.c
> > @@ -192,7 +192,7 @@ static int rpl_read_header(AVFormatContext *s)
> >  // samples, though. This code will ignore additional tracks.
> >  error |= read_line(pb, line, sizeof(line));
> >  audio_format = read_int(line, &endptr, &error);  // audio format ID
> > -strcpy(audio_codec, endptr);
> > +av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
> >  if (audio_format) {
> >  ast = avformat_new_stream(s, NULL);
> >  if (!ast)
> > @@ -203,7 +203,7 @@ static int rpl_read_header(AVFormatContext *s)
> >  ast->codecpar->channels= read_line_and_int(pb,
> &error);  // number of audio channels
> >  error |= read_line(pb, line, sizeof(line));
> >  ast->codecpar->bits_per_coded_sample = read_int(line, &endptr,
> &error);  // audio bits per sample
> > -strcpy(audio_type, endptr);
> > +av_strlcpy(audio_type, endptr, RPL_LINE_LENGTH);
> >  // At least one sample uses 0 for ADPCM, which is really 4 bits
> >  // per sample.
> >  if (ast->codecpar->bits_per_coded_sample == 0)
>
> please include this in the patch that adds the strcpy()
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-07-05 Thread Cameron Cawley
Samples are available from
http://riscos.com/ftp_space/370/files/diversions.zip (in the "AudioDemos"
folder) and http://riscos.com/ftp_space/370/files/sound.zip (the files
"1812" and "Enigma").

On Fri, 5 Jul 2019 at 17:16, Michael Niedermayer 
wrote:

> On Thu, Jun 27, 2019 at 08:56:01PM +0100, Cameron Cawley wrote:
> > Signed-off-by: Cameron Cawley 
> > ---
> >  doc/general.texi|  1 +
> >  libavcodec/Makefile |  1 +
> >  libavcodec/adpcm.c  | 14 ++
> >  libavcodec/allcodecs.c  |  1 +
> >  libavcodec/avcodec.h|  1 +
> >  libavcodec/codec_desc.c |  7 +++
> >  libavcodec/utils.c  |  1 +
> >  7 files changed, 26 insertions(+)
> >
> > diff --git a/doc/general.texi b/doc/general.texi
> > index ed3cdfcf99..fbbbc24753 100644
> > --- a/doc/general.texi
> > +++ b/doc/general.texi
> > @@ -1070,6 +1070,7 @@ following image formats are supported:
> >  @item ADPCM Electronic Arts XAS @tab @tab  X
> >  @item ADPCM G.722@tab  X  @tab  X
> >  @item ADPCM G.726@tab  X  @tab  X
> > +@item ADPCM IMA Acorn Replay @tab @tab  X
> >  @item ADPCM IMA AMV  @tab @tab  X
> >  @tab Used in AMV files
> >  @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index edccd73037..9c0dd5d189 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -825,6 +825,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
> >  OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
> >  OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
> >  OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
> > +OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
> >  OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
> >  OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
> >  OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
> > diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> > index ede0130bf1..1d4b4d2c22 100644
> > --- a/libavcodec/adpcm.c
> > +++ b/libavcodec/adpcm.c
> > @@ -594,6 +594,7 @@ static int get_nb_samples(AVCodecContext *avctx,
> GetByteContext *gb,
> >  switch (avctx->codec->id) {
> >  case AV_CODEC_ID_ADPCM_4XM:
> >  case AV_CODEC_ID_ADPCM_AGM:
> > +case AV_CODEC_ID_ADPCM_IMA_ACORN:
> >  case AV_CODEC_ID_ADPCM_IMA_DAT4:
> >  case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;
> break;
> >  case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8;
>  break;
> > @@ -1412,6 +1413,18 @@ static int adpcm_decode_frame(AVCodecContext
> *avctx, void *data,
> >  }
> >  }
> >  break;
> > +case AV_CODEC_ID_ADPCM_IMA_ACORN:
> > +for (i=0; i<=st; i++) {
> > +bytestream2_skip(&gb, 2); // TODO: What does this do?
> > +c->status[i].step_index = bytestream2_get_le16u(&gb);
> > +}
>
> where can we find such adpcm files for testing ?
>
> 2 bytes per stream could be initial raw pcm samples
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No great genius has ever existed without some touch of madness. --
> Aristotle
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/2] avformat/rpl: Replace strcpy with av_strlcpy

2019-07-03 Thread Cameron Cawley
The patch should be applied on top of the Replay ADPCM patches.

Regards
Cameron


On Mon, 1 Jul 2019 at 15:07, Michael Niedermayer 
wrote:

> On Sun, Jun 30, 2019 at 12:00:43AM +0100, Cameron Cawley wrote:
> > ---
> >  libavformat/rpl.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
>
> this doesnt apply, against which branch is that patch ?


> thx
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> It is what and why we do it that matters, not just one of them.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Calculate the duration of the video track

2019-06-29 Thread Cameron Cawley
---
 libavformat/rpl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 579ab4f57e..d31c7f09ad 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -280,8 +280,10 @@ static int rpl_read_header(AVFormatContext *s)
 read_line_and_int(pb, &error);   //   (file index)
 error |= read_line(pb, line, sizeof(line));  // offset to "helpful" sprite
 error |= read_line(pb, line, sizeof(line));  // size of "helpful" sprite
-if (vst)
+if (vst) {
 error |= read_line(pb, line, sizeof(line));  // offset to key frame 
list
+vst->duration = number_of_chunks * rpl->frames_per_chunk;
+}
 
 // Read the index
 avio_seek(pb, chunk_catalog_offset, SEEK_SET);
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avformat/rpl: Replace strcpy with av_strlcpy

2019-06-29 Thread Cameron Cawley
---
 libavformat/rpl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index b4859320f4..579ab4f57e 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -192,7 +192,7 @@ static int rpl_read_header(AVFormatContext *s)
 // samples, though. This code will ignore additional tracks.
 error |= read_line(pb, line, sizeof(line));
 audio_format = read_int(line, &endptr, &error);  // audio format ID
-strcpy(audio_codec, endptr);
+av_strlcpy(audio_codec, endptr, RPL_LINE_LENGTH);
 if (audio_format) {
 ast = avformat_new_stream(s, NULL);
 if (!ast)
@@ -203,7 +203,7 @@ static int rpl_read_header(AVFormatContext *s)
 ast->codecpar->channels= read_line_and_int(pb, &error);  // 
number of audio channels
 error |= read_line(pb, line, sizeof(line));
 ast->codecpar->bits_per_coded_sample = read_int(line, &endptr, 
&error);  // audio bits per sample
-strcpy(audio_type, endptr);
+av_strlcpy(audio_type, endptr, RPL_LINE_LENGTH);
 // At least one sample uses 0 for ADPCM, which is really 4 bits
 // per sample.
 if (ast->codecpar->bits_per_coded_sample == 0)
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Support files containing Replay IMA ADPCM audio

2019-06-27 Thread Cameron Cawley
---
 libavformat/rpl.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index dbbcd13b41..b4859320f4 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -121,6 +121,7 @@ static int rpl_read_header(AVFormatContext *s)
 int error = 0;
 const char *endptr;
 char audio_type[RPL_LINE_LENGTH];
+char audio_codec[RPL_LINE_LENGTH];
 
 uint32_t i;
 
@@ -189,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
 
 // ARMovie supports multiple audio tracks; I don't have any
 // samples, though. This code will ignore additional tracks.
-audio_format = read_line_and_int(pb, &error);  // audio format ID
+error |= read_line(pb, line, sizeof(line));
+audio_format = read_int(line, &endptr, &error);  // audio format ID
+strcpy(audio_codec, endptr);
 if (audio_format) {
 ast = avformat_new_stream(s, NULL);
 if (!ast)
@@ -229,6 +232,14 @@ static int rpl_read_header(AVFormatContext *s)
 break;
 }
 }
+break;
+case 2:
+if (av_strcasecmp(audio_codec," adpcm") == 0) {
+ast->codecpar->codec_id = AV_CODEC_ID_ADPCM_IMA_ACORN;
+} else {
+avpriv_report_missing_feature(s, "Audio format %"PRId32" 
(%s)",
+  audio_format, audio_codec);
+}
 // There are some other formats listed as legal per the spec;
 // samples needed.
 break;
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avcodec: Implement Acorn Replay IMA ADPCM decoder

2019-06-27 Thread Cameron Cawley
Signed-off-by: Cameron Cawley 
---
 doc/general.texi|  1 +
 libavcodec/Makefile |  1 +
 libavcodec/adpcm.c  | 14 ++
 libavcodec/allcodecs.c  |  1 +
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  7 +++
 libavcodec/utils.c  |  1 +
 7 files changed, 26 insertions(+)

diff --git a/doc/general.texi b/doc/general.texi
index ed3cdfcf99..fbbbc24753 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -1070,6 +1070,7 @@ following image formats are supported:
 @item ADPCM Electronic Arts XAS @tab @tab  X
 @item ADPCM G.722@tab  X  @tab  X
 @item ADPCM G.726@tab  X  @tab  X
+@item ADPCM IMA Acorn Replay @tab @tab  X
 @item ADPCM IMA AMV  @tab @tab  X
 @tab Used in AMV files
 @item ADPCM IMA Electronic Arts EACS  @tab @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index edccd73037..9c0dd5d189 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -825,6 +825,7 @@ OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_DECODER)   += g726.o
 OBJS-$(CONFIG_ADPCM_G726LE_ENCODER)   += g726.o
+OBJS-$(CONFIG_ADPCM_IMA_ACORN_DECODER)+= adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_APC_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_IMA_DAT4_DECODER) += adpcm.o adpcm_data.o
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index ede0130bf1..1d4b4d2c22 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -594,6 +594,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
GetByteContext *gb,
 switch (avctx->codec->id) {
 case AV_CODEC_ID_ADPCM_4XM:
 case AV_CODEC_ID_ADPCM_AGM:
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
 case AV_CODEC_ID_ADPCM_IMA_DAT4:
 case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch;  break;
 case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8;   break;
@@ -1412,6 +1413,18 @@ static int adpcm_decode_frame(AVCodecContext *avctx, 
void *data,
 }
 }
 break;
+case AV_CODEC_ID_ADPCM_IMA_ACORN:
+for (i=0; i<=st; i++) {
+bytestream2_skip(&gb, 2); // TODO: What does this do?
+c->status[i].step_index = bytestream2_get_le16u(&gb);
+}
+
+for (n = nb_samples >> (1 - st); n > 0; n--) {
+int byte = bytestream2_get_byteu(&gb);
+*samples++ = adpcm_ima_expand_nibble(&c->status[0],  byte & 0x0F, 
6);
+*samples++ = adpcm_ima_expand_nibble(&c->status[st], byte >> 4,   
6);
+}
+break;
 case AV_CODEC_ID_ADPCM_IMA_AMV:
 c->status[0].predictor = sign_extend(bytestream2_get_le16u(&gb), 16);
 c->status[0].step_index = bytestream2_get_byteu(&gb);
@@ -1796,6 +1809,7 @@ ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R1,   
sample_fmts_s16p, adpcm_ea_r1,
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R2,   sample_fmts_s16p, adpcm_ea_r2,
   "ADPCM Electronic Arts R2");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_R3,   sample_fmts_s16p, adpcm_ea_r3,
   "ADPCM Electronic Arts R3");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_EA_XAS,  sample_fmts_s16p, adpcm_ea_xas,   
   "ADPCM Electronic Arts XAS");
+ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_ACORN,   sample_fmts_s16,  
adpcm_ima_acorn,   "ADPCM IMA Acorn Replay");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_AMV, sample_fmts_s16,  adpcm_ima_amv,  
   "ADPCM IMA AMV");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_APC, sample_fmts_s16,  adpcm_ima_apc,  
   "ADPCM IMA CRYO APC");
 ADPCM_DECODER(AV_CODEC_ID_ADPCM_IMA_DAT4,sample_fmts_s16,  adpcm_ima_dat4, 
   "ADPCM IMA Eurocom DAT4");
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index d2f9a39ce5..78177a1255 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -592,6 +592,7 @@ extern AVCodec ff_adpcm_g726_encoder;
 extern AVCodec ff_adpcm_g726_decoder;
 extern AVCodec ff_adpcm_g726le_encoder;
 extern AVCodec ff_adpcm_g726le_decoder;
+extern AVCodec ff_adpcm_ima_acorn_decoder;
 extern AVCodec ff_adpcm_ima_amv_decoder;
 extern AVCodec ff_adpcm_ima_apc_decoder;
 extern AVCodec ff_adpcm_ima_dat4_decoder;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 586bbbca4e..f2e8f27c75 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -542,6 +542,7 @@ enum AVCodecID {
 AV_CODEC_ID_ADPCM_IMA_DAT4,
 AV_CODEC_ID_ADPCM_MTAF,
 AV_CODEC_ID_ADPCM_AGM,
+AV_CODEC_ID_ADPCM_IMA_ACORN,
 
 /* AMR */
 AV_CODEC_ID_AMR_NB = 0x12000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 4d033c20ff..dc39b50e33 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -2276,6 +2276,13 @@ static const AVCodecDescriptor c

[FFmpeg-devel] [PATCH 1/2] avformat/rpl: Fix detection of 8-bit linear formats

2019-06-14 Thread Cameron Cawley
Was previously broken by commit 8cf5f94.
Fixes ticket #7859

Signed-off-by: Cameron Cawley 
---
 libavformat/rpl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 7aec3503da..683b3a835a 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -210,10 +210,10 @@ static int rpl_read_header(AVFormatContext *s)
 ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
 break;
 } else if (ast->codecpar->bits_per_coded_sample == 8) {
-if(av_strcasecmp(audio_type, "unsigned") >= 0) {
+if(av_stristr(audio_type, "unsigned") != NULL) {
 ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
 break;
-} else if(av_strcasecmp(audio_type, "linear") >= 0) {
+} else if(av_stristr(audio_type, "linear") != NULL) {
 ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
 break;
 } else {
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Allow a file to have audio, but not video

2019-06-14 Thread Cameron Cawley
Signed-off-by: Cameron Cawley 
---
 libavformat/rpl.c | 78 +++
 1 file changed, 44 insertions(+), 34 deletions(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 683b3a835a..dbbcd13b41 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -124,7 +124,7 @@ static int rpl_read_header(AVFormatContext *s)
 
 uint32_t i;
 
-int32_t audio_format, chunk_catalog_offset, number_of_chunks;
+int32_t video_format, audio_format, chunk_catalog_offset, number_of_chunks;
 AVRational fps;
 
 char line[RPL_LINE_LENGTH];
@@ -144,39 +144,47 @@ static int rpl_read_header(AVFormatContext *s)
 av_dict_set(&s->metadata, "author"   , line, 0);
 
 // video headers
-vst = avformat_new_stream(s, NULL);
-if (!vst)
-return AVERROR(ENOMEM);
-vst->codecpar->codec_type  = AVMEDIA_TYPE_VIDEO;
-vst->codecpar->codec_tag   = read_line_and_int(pb, &error);  // video 
format
-vst->codecpar->width   = read_line_and_int(pb, &error);  // video 
width
-vst->codecpar->height  = read_line_and_int(pb, &error);  // video 
height
-vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error);  // 
video bits per sample
-error |= read_line(pb, line, sizeof(line));   // video 
frames per second
-fps = read_fps(line, &error);
-avpriv_set_pts_info(vst, 32, fps.den, fps.num);
-
-// Figure out the video codec
-switch (vst->codecpar->codec_tag) {
+video_format = read_line_and_int(pb, &error);
+if (video_format) {
+vst = avformat_new_stream(s, NULL);
+if (!vst)
+return AVERROR(ENOMEM);
+vst->codecpar->codec_type  = AVMEDIA_TYPE_VIDEO;
+vst->codecpar->codec_tag   = video_format;
+vst->codecpar->width   = read_line_and_int(pb, &error);  // 
video width
+vst->codecpar->height  = read_line_and_int(pb, &error);  // 
video height
+vst->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error);  
// video bits per sample
+
+// Figure out the video codec
+switch (vst->codecpar->codec_tag) {
 #if 0
-case 122:
-vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE122;
-break;
+case 122:
+vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE122;
+break;
 #endif
-case 124:
-vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE124;
-// The header is wrong here, at least sometimes
-vst->codecpar->bits_per_coded_sample = 16;
-break;
-case 130:
-vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE130;
-break;
-default:
-avpriv_report_missing_feature(s, "Video format %s",
-  
av_fourcc2str(vst->codecpar->codec_tag));
-vst->codecpar->codec_id = AV_CODEC_ID_NONE;
+case 124:
+vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE124;
+// The header is wrong here, at least sometimes
+vst->codecpar->bits_per_coded_sample = 16;
+break;
+case 130:
+vst->codecpar->codec_id = AV_CODEC_ID_ESCAPE130;
+break;
+default:
+avpriv_report_missing_feature(s, "Video format %s",
+  
av_fourcc2str(vst->codecpar->codec_tag));
+vst->codecpar->codec_id = AV_CODEC_ID_NONE;
+}
+} else {
+for (i = 0; i < 3; i++)
+error |= read_line(pb, line, sizeof(line));
 }
 
+error |= read_line(pb, line, sizeof(line));   // video 
frames per second
+fps = read_fps(line, &error);
+if (vst)
+avpriv_set_pts_info(vst, 32, fps.den, fps.num);
+
 // Audio headers
 
 // ARMovie supports multiple audio tracks; I don't have any
@@ -246,7 +254,7 @@ static int rpl_read_header(AVFormatContext *s)
 }
 
 rpl->frames_per_chunk = read_line_and_int(pb, &error);  // video frames 
per chunk
-if (rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124)
+if (vst && rpl->frames_per_chunk > 1 && vst->codecpar->codec_tag != 124)
 av_log(s, AV_LOG_WARNING,
"Don't know how to split frames for video format %s. "
"Video stream will be broken!\n", 
av_fourcc2str(vst->codecpar->codec_tag));
@@ -261,7 +269,8 @@ static int rpl_read_header(AVFormatContext *s)
 read_line_and_int(pb, &error);   //   (file index)
 error |= read_line(pb, line, sizeof(line));  // off

Re: [FFmpeg-devel] [PATCH 1/2] avcodec: Implement Archimedes VIDC encoder/decoder

2018-10-25 Thread Cameron Cawley
> Are there files available so I can test this?

Various sample files can be found at
http://samples.mplayerhq.hu/archive/container/rpl/ and
ftp://ftp.uni-stuttgart.de/pub/systems/acorn/riscos/graphics/replay . Most
of them use VIDC for audio.

On Thu, 25 Oct 2018 at 18:28, Paul B Mahol  wrote:

> On 10/13/18, Cameron Cawley  wrote:
> > Signed-off-by: Cameron Cawley 
> > ---
> >  doc/general.texi  |  2 ++
> >  libavcodec/Makefile   |  2 ++
> >  libavcodec/allcodecs.c|  2 ++
> >  libavcodec/avcodec.h  |  1 +
> >  libavcodec/codec_desc.c   |  7 +++
> >  libavcodec/pcm.c  | 15 +++
> >  libavcodec/pcm_tablegen.c |  2 ++
> >  libavcodec/pcm_tablegen.h | 27 +++
> >  libavcodec/utils.c|  1 +
> >  libavformat/Makefile  |  2 ++
> >  libavformat/allformats.c  |  2 ++
> >  libavformat/pcmdec.c  |  3 +++
> >  libavformat/pcmenc.c  |  3 +++
> >  13 files changed, 69 insertions(+)
> >
>
> Are there files available so I can test this?
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] avcodec: Implement Archimedes VIDC encoder/decoder

2018-10-12 Thread Cameron Cawley
Signed-off-by: Cameron Cawley 
---
 doc/general.texi  |  2 ++
 libavcodec/Makefile   |  2 ++
 libavcodec/allcodecs.c|  2 ++
 libavcodec/avcodec.h  |  1 +
 libavcodec/codec_desc.c   |  7 +++
 libavcodec/pcm.c  | 15 +++
 libavcodec/pcm_tablegen.c |  2 ++
 libavcodec/pcm_tablegen.h | 27 +++
 libavcodec/utils.c|  1 +
 libavformat/Makefile  |  2 ++
 libavformat/allformats.c  |  2 ++
 libavformat/pcmdec.c  |  3 +++
 libavformat/pcmenc.c  |  3 +++
 13 files changed, 69 insertions(+)

diff --git a/doc/general.texi b/doc/general.texi
index 05f7bcd9fc..e3874430a4 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -545,6 +545,7 @@ library:
 @item raw VC-1  @tab X @tab X
 @item raw PCM A-law @tab X @tab X
 @item raw PCM mu-law@tab X @tab X
+@item raw PCM Archimedes VIDC   @tab X @tab X
 @item raw PCM signed 8 bit  @tab X @tab X
 @item raw PCM signed 16 bit big-endian  @tab X @tab X
 @item raw PCM signed 16 bit little-endian  @tab X @tab X
@@ -1146,6 +1147,7 @@ following image formats are supported:
 @tab encoding supported through external library libopus
 @item PCM A-law  @tab  X  @tab  X
 @item PCM mu-law @tab  X  @tab  X
+@item PCM Archimedes VIDC@tab  X  @tab  X
 @item PCM signed 8-bit planar  @tab  X  @tab  X
 @item PCM signed 16-bit big-endian planar  @tab  X  @tab  X
 @item PCM signed 16-bit little-endian planar  @tab  X  @tab  X
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index ce766aa466..b12d9ffccd 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -794,6 +794,8 @@ OBJS-$(CONFIG_PCM_U32BE_DECODER)  += pcm.o
 OBJS-$(CONFIG_PCM_U32BE_ENCODER)  += pcm.o
 OBJS-$(CONFIG_PCM_U32LE_DECODER)  += pcm.o
 OBJS-$(CONFIG_PCM_U32LE_ENCODER)  += pcm.o
+OBJS-$(CONFIG_PCM_VIDC_DECODER)   += pcm.o
+OBJS-$(CONFIG_PCM_VIDC_ENCODER)   += pcm.o
 OBJS-$(CONFIG_PCM_ZORK_DECODER)   += pcm.o
 
 OBJS-$(CONFIG_ADPCM_4XM_DECODER)  += adpcm.o adpcm_data.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index c0b4d56d0d..1b8144a2b7 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -552,6 +552,8 @@ extern AVCodec ff_pcm_u32be_encoder;
 extern AVCodec ff_pcm_u32be_decoder;
 extern AVCodec ff_pcm_u32le_encoder;
 extern AVCodec ff_pcm_u32le_decoder;
+extern AVCodec ff_pcm_vidc_encoder;
+extern AVCodec ff_pcm_vidc_decoder;
 extern AVCodec ff_pcm_zork_decoder;
 
 /* DPCM codecs */
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 705a3ce4f3..7ffef768dc 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -491,6 +491,7 @@ enum AVCodecID {
 AV_CODEC_ID_PCM_S64BE,
 AV_CODEC_ID_PCM_F16LE,
 AV_CODEC_ID_PCM_F24LE,
+AV_CODEC_ID_PCM_VIDC,
 
 /* various ADPCM codecs */
 AV_CODEC_ID_ADPCM_IMA_QT = 0x11000,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index 67a30542d1..1a159f7e13 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -1936,6 +1936,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .long_name = NULL_IF_CONFIG_SMALL("PCM 24.0 floating point 
little-endian"),
 .props = AV_CODEC_PROP_LOSSLESS,
 },
+{
+.id= AV_CODEC_ID_PCM_VIDC,
+.type  = AVMEDIA_TYPE_AUDIO,
+.name  = "pcm_vidc",
+.long_name = NULL_IF_CONFIG_SMALL("PCM Archimedes VIDC"),
+.props = AV_CODEC_PROP_LOSSY,
+},
 
 /* various ADPCM codecs */
 {
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 8c326c6829..ffcbccc77d 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -42,6 +42,9 @@ static av_cold int pcm_encode_init(AVCodecContext *avctx)
 case AV_CODEC_ID_PCM_MULAW:
 pcm_ulaw_tableinit();
 break;
+case AV_CODEC_ID_PCM_VIDC:
+pcm_vidc_tableinit();
+break;
 default:
 break;
 }
@@ -216,6 +219,12 @@ static int pcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 *dst++ = linear_to_ulaw[(v + 32768) >> 2];
 }
 break;
+case AV_CODEC_ID_PCM_VIDC:
+for (; n > 0; n--) {
+v  = *samples++;
+*dst++ = linear_to_vidc[(v + 32768) >> 2];
+}
+break;
 default:
 return -1;
 }
@@ -249,6 +258,10 @@ static av_cold int pcm_decode_init(AVCodecContext *avctx)
 for (i = 0; i < 256; i++)
 s->table[i] = ulaw2linear(i);
 break;
+case AV_CODEC_ID_PCM_VIDC:
+for (i = 0; i < 256; i++)
+s->table[i] = vidc2linear(i);
+break;
 case AV_CODEC_ID_PCM_F16LE:
 case AV_CODEC_ID_PCM_F24LE:
 s->scale = 1. / (1 << (avctx->bits_per_coded_sample - 1));
@@ -485,6 +498,7 @@ static int pcm_decode_frame(AVCodecContext *avctx, void 
*data,
 b

[FFmpeg-devel] [PATCH 2/2] avformat/rpl: Support files containing 8 bit PCM or VIDC audio

2018-10-12 Thread Cameron Cawley
Signed-off-by: Cameron Cawley 
---
 libavformat/rpl.c | 17 -
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index d373600478..6b45b35c30 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -119,6 +119,8 @@ static int rpl_read_header(AVFormatContext *s)
 AVStream *vst = NULL, *ast = NULL;
 int total_audio_size;
 int error = 0;
+const char *endptr;
+char audio_type[RPL_LINE_LENGTH];
 
 uint32_t i;
 
@@ -188,7 +190,9 @@ static int rpl_read_header(AVFormatContext *s)
 ast->codecpar->codec_tag   = audio_format;
 ast->codecpar->sample_rate = read_line_and_int(pb, &error);  // 
audio bitrate
 ast->codecpar->channels= read_line_and_int(pb, &error);  // 
number of audio channels
-ast->codecpar->bits_per_coded_sample = read_line_and_int(pb, &error);  
// audio bits per sample
+error |= read_line(pb, line, sizeof(line));
+ast->codecpar->bits_per_coded_sample = read_int(line, &endptr, 
&error);  // audio bits per sample
+strcpy(audio_type, endptr);
 // At least one sample uses 0 for ADPCM, which is really 4 bits
 // per sample.
 if (ast->codecpar->bits_per_coded_sample == 0)
@@ -205,6 +209,17 @@ static int rpl_read_header(AVFormatContext *s)
 // 16-bit audio is always signed
 ast->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE;
 break;
+} else if (ast->codecpar->bits_per_coded_sample == 8) {
+if(strstr(audio_type, "unsigned") != NULL) {
+ast->codecpar->codec_id = AV_CODEC_ID_PCM_U8;
+break;
+} else if(strstr(audio_type, "linear") != NULL) {
+ast->codecpar->codec_id = AV_CODEC_ID_PCM_S8;
+break;
+} else {
+ast->codecpar->codec_id = AV_CODEC_ID_PCM_VIDC;
+break;
+}
 }
 // There are some other formats listed as legal per the spec;
 // samples needed.
-- 
2.11.0

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel