Commit 5616f85d authored by Baptiste Coudurier's avatar Baptiste Coudurier

clean and simplify mov_write_packet

Originally committed as revision 5289 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent b548f2b9
...@@ -1641,12 +1641,10 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -1641,12 +1641,10 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
if (url_is_streamed(&s->pb)) return 0; /* Can't handle that */ if (url_is_streamed(&s->pb)) return 0; /* Can't handle that */
if (!size) return 0; /* Discard 0 sized packets */ if (!size) return 0; /* Discard 0 sized packets */
if (enc->codec_type == CODEC_TYPE_VIDEO ) { if (enc->codec_type == CODEC_TYPE_AUDIO) {
samplesInChunk = 1; switch (enc->codec_id) {
} case CODEC_ID_AMR_NB:
else if (enc->codec_type == CODEC_TYPE_AUDIO ) { { /* We must find out how many AMR blocks there are in one packet */
if( enc->codec_id == CODEC_ID_AMR_NB) {
/* We must find out how many AMR blocks there are in one packet */
static uint16_t packed_size[16] = static uint16_t packed_size[16] =
{13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0};
int len = 0; int len = 0;
...@@ -1656,41 +1654,35 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -1656,41 +1654,35 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
samplesInChunk++; samplesInChunk++;
} }
} }
else if(enc->codec_id == CODEC_ID_PCM_ALAW) { break;
case CODEC_ID_PCM_ALAW:
samplesInChunk = size/enc->channels; samplesInChunk = size/enc->channels;
} break;
else if(enc->codec_id == CODEC_ID_PCM_S16BE || enc->codec_id == CODEC_ID_PCM_S16LE) { case CODEC_ID_PCM_S16BE:
case CODEC_ID_PCM_S16LE:
samplesInChunk = size/(2*enc->channels); samplesInChunk = size/(2*enc->channels);
} break;
else { default:
samplesInChunk = 1; samplesInChunk = 1;
} }
} else {
samplesInChunk = 1;
} }
if ((enc->codec_id == CODEC_ID_MPEG4 || enc->codec_id == CODEC_ID_AAC) /* copy extradata if it exists */
&& trk->vosLen == 0) { if (trk->vosLen == 0 && enc->extradata_size > 0) {
// assert(enc->extradata_size);
trk->vosLen = enc->extradata_size; trk->vosLen = enc->extradata_size;
trk->vosData = av_malloc(trk->vosLen); trk->vosData = av_malloc(trk->vosLen);
memcpy(trk->vosData, enc->extradata, trk->vosLen); memcpy(trk->vosData, enc->extradata, trk->vosLen);
} }
if (enc->codec_id == CODEC_ID_H264) { if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) {
if (trk->vosLen == 0) {
/* copy extradata */
trk->vosLen = enc->extradata_size;
trk->vosData = av_malloc(trk->vosLen);
memcpy(trk->vosData, enc->extradata, trk->vosLen);
}
if (*(uint8_t *)trk->vosData != 1) {
/* from x264 or from bytestream h264 */ /* from x264 or from bytestream h264 */
/* nal reformating needed */ /* nal reformating needed */
avc_parse_nal_units(&pkt->data, &pkt->size); avc_parse_nal_units(&pkt->data, &pkt->size);
assert(pkt->size); assert(pkt->size);
size = pkt->size; size = pkt->size;
} }
}
cl = trk->entry / MOV_INDEX_CLUSTER_SIZE; cl = trk->entry / MOV_INDEX_CLUSTER_SIZE;
id = trk->entry % MOV_INDEX_CLUSTER_SIZE; id = trk->entry % MOV_INDEX_CLUSTER_SIZE;
......
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