[v2,2/5] mov: Support muxing/demuxing iLBC

Message ID 1340008803-89076-2-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö June 18, 2012, 8:40 a.m.
The packet size, signalled via block_align, has to be passed via
the container.
---
 libavformat/isom.c   |    1 +
 libavformat/mov.c    |    1 +
 libavformat/movenc.c |    3 ++-
 3 files changed, 4 insertions(+), 1 deletion(-)

Comments

Justin Ruggles June 18, 2012, 2:39 p.m. | #1
On 06/18/2012 04:40 AM, Martin Storsjö wrote:
> The packet size, signalled via block_align, has to be passed via
> the container.
> ---
>  libavformat/isom.c   |    1 +
>  libavformat/mov.c    |    1 +
>  libavformat/movenc.c |    3 ++-
>  3 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 3ea8ce1..e5cde5a 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -244,6 +244,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
>      { CODEC_ID_DVAUDIO,         MKTAG('v', 'd', 'v', 'a') },
>      { CODEC_ID_DVAUDIO,         MKTAG('d', 'v', 'c', 'a') },
>      { CODEC_ID_GSM,             MKTAG('a', 'g', 's', 'm') },
> +    { CODEC_ID_ILBC,            MKTAG('i', 'l', 'b', 'c') },
>      { CODEC_ID_MACE3,           MKTAG('M', 'A', 'C', '3') },
>      { CODEC_ID_MACE6,           MKTAG('M', 'A', 'C', '6') },
>      { CODEC_ID_MP1,             MKTAG('.', 'm', 'p', '1') },
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 1395259..44dc2c8 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1456,6 +1456,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
>      case CODEC_ID_GSM:
>      case CODEC_ID_ADPCM_MS:
>      case CODEC_ID_ADPCM_IMA_WAV:
> +    case CODEC_ID_ILBC:
>          st->codec->block_align = sc->bytes_per_frame;
>          break;
>      case CODEC_ID_ALAC:
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index bf888bc..350ac95 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -3095,7 +3095,8 @@ static int mov_write_header(AVFormatContext *s)
>          }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
>              track->timescale = st->codec->sample_rate;
>              /* set sample_size for PCM and ADPCM */
> -            if (av_get_bits_per_sample(st->codec->codec_id)) {
> +            if (av_get_bits_per_sample(st->codec->codec_id) ||
> +                st->codec->codec_id == CODEC_ID_ILBC) {
>                  if (!st->codec->block_align) {
>                      av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
>                      goto error;

LGTM

-Justin

Patch

diff --git a/libavformat/isom.c b/libavformat/isom.c
index 3ea8ce1..e5cde5a 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -244,6 +244,7 @@  const AVCodecTag ff_codec_movaudio_tags[] = {
     { CODEC_ID_DVAUDIO,         MKTAG('v', 'd', 'v', 'a') },
     { CODEC_ID_DVAUDIO,         MKTAG('d', 'v', 'c', 'a') },
     { CODEC_ID_GSM,             MKTAG('a', 'g', 's', 'm') },
+    { CODEC_ID_ILBC,            MKTAG('i', 'l', 'b', 'c') },
     { CODEC_ID_MACE3,           MKTAG('M', 'A', 'C', '3') },
     { CODEC_ID_MACE6,           MKTAG('M', 'A', 'C', '6') },
     { CODEC_ID_MP1,             MKTAG('.', 'm', 'p', '1') },
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1395259..44dc2c8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1456,6 +1456,7 @@  int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
     case CODEC_ID_GSM:
     case CODEC_ID_ADPCM_MS:
     case CODEC_ID_ADPCM_IMA_WAV:
+    case CODEC_ID_ILBC:
         st->codec->block_align = sc->bytes_per_frame;
         break;
     case CODEC_ID_ALAC:
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index bf888bc..350ac95 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3095,7 +3095,8 @@  static int mov_write_header(AVFormatContext *s)
         }else if(st->codec->codec_type == AVMEDIA_TYPE_AUDIO){
             track->timescale = st->codec->sample_rate;
             /* set sample_size for PCM and ADPCM */
-            if (av_get_bits_per_sample(st->codec->codec_id)) {
+            if (av_get_bits_per_sample(st->codec->codec_id) ||
+                st->codec->codec_id == CODEC_ID_ILBC) {
                 if (!st->codec->block_align) {
                     av_log(s, AV_LOG_ERROR, "track %d: codec block align is not set\n", i);
                     goto error;