rtpdec_h264: Cosmetic cleanup
Add/fix spacing, split long lines, align assignments where suitable. Signed-off-by: Diego Biurrun <diego@biurrun.de> Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
f3d471f45f
commit
0b3ac9fe05
@ -86,11 +86,15 @@ static int sdp_parse_fmtp_config_h264(AVStream * stream,
|
|||||||
uint8_t profile_iop;
|
uint8_t profile_iop;
|
||||||
uint8_t level_idc;
|
uint8_t level_idc;
|
||||||
|
|
||||||
buffer[0] = value[0]; buffer[1] = value[1]; buffer[2] = '\0';
|
buffer[0] = value[0];
|
||||||
|
buffer[1] = value[1];
|
||||||
|
buffer[2] = '\0';
|
||||||
profile_idc = strtol(buffer, NULL, 16);
|
profile_idc = strtol(buffer, NULL, 16);
|
||||||
buffer[0] = value[2]; buffer[1] = value[3];
|
buffer[0] = value[2];
|
||||||
|
buffer[1] = value[3];
|
||||||
profile_iop = strtol(buffer, NULL, 16);
|
profile_iop = strtol(buffer, NULL, 16);
|
||||||
buffer[0] = value[4]; buffer[1] = value[5];
|
buffer[0] = value[4];
|
||||||
|
buffer[1] = value[5];
|
||||||
level_idc = strtol(buffer, NULL, 16);
|
level_idc = strtol(buffer, NULL, 16);
|
||||||
|
|
||||||
av_log(codec, AV_LOG_DEBUG,
|
av_log(codec, AV_LOG_DEBUG,
|
||||||
@ -120,45 +124,44 @@ static int sdp_parse_fmtp_config_h264(AVStream * stream,
|
|||||||
if (*value == ',')
|
if (*value == ',')
|
||||||
value++;
|
value++;
|
||||||
|
|
||||||
packet_size= av_base64_decode(decoded_packet, base64packet, sizeof(decoded_packet));
|
packet_size = av_base64_decode(decoded_packet, base64packet,
|
||||||
|
sizeof(decoded_packet));
|
||||||
if (packet_size > 0) {
|
if (packet_size > 0) {
|
||||||
uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) +
|
uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) +
|
||||||
codec->extradata_size +
|
codec->extradata_size +
|
||||||
FF_INPUT_BUFFER_PADDING_SIZE);
|
FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
if(dest)
|
if (dest) {
|
||||||
{
|
if (codec->extradata_size) {
|
||||||
if(codec->extradata_size)
|
|
||||||
{
|
|
||||||
memcpy(dest, codec->extradata, codec->extradata_size);
|
memcpy(dest, codec->extradata, codec->extradata_size);
|
||||||
av_free(codec->extradata);
|
av_free(codec->extradata);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(dest+codec->extradata_size, start_sequence, sizeof(start_sequence));
|
memcpy(dest + codec->extradata_size, start_sequence,
|
||||||
memcpy(dest+codec->extradata_size+sizeof(start_sequence), decoded_packet, packet_size);
|
sizeof(start_sequence));
|
||||||
|
memcpy(dest + codec->extradata_size + sizeof(start_sequence),
|
||||||
|
decoded_packet, packet_size);
|
||||||
memset(dest + codec->extradata_size + sizeof(start_sequence) +
|
memset(dest + codec->extradata_size + sizeof(start_sequence) +
|
||||||
packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
|
||||||
codec->extradata = dest;
|
codec->extradata = dest;
|
||||||
codec->extradata_size += sizeof(start_sequence) + packet_size;
|
codec->extradata_size += sizeof(start_sequence) + packet_size;
|
||||||
} else {
|
} else {
|
||||||
av_log(codec, AV_LOG_ERROR, "Unable to allocate memory for extradata!");
|
av_log(codec, AV_LOG_ERROR,
|
||||||
|
"Unable to allocate memory for extradata!");
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_log(codec, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!", codec->extradata, codec->extradata_size);
|
av_log(codec, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!",
|
||||||
|
codec->extradata, codec->extradata_size);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return 0 on packet, no more left, 1 on packet, 1 on partial packet
|
// return 0 on packet, no more left, 1 on packet, 1 on partial packet
|
||||||
static int h264_handle_packet(AVFormatContext *ctx,
|
static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data,
|
||||||
PayloadContext *data,
|
AVStream *st, AVPacket *pkt, uint32_t *timestamp,
|
||||||
AVStream *st,
|
const uint8_t *buf, int len, int flags)
|
||||||
AVPacket * pkt,
|
|
||||||
uint32_t * timestamp,
|
|
||||||
const uint8_t * buf,
|
|
||||||
int len, int flags)
|
|
||||||
{
|
{
|
||||||
uint8_t nal;
|
uint8_t nal;
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
@ -271,13 +274,13 @@ static int h264_handle_packet(AVFormatContext *ctx,
|
|||||||
uint8_t fu_header = *buf;
|
uint8_t fu_header = *buf;
|
||||||
uint8_t start_bit = fu_header >> 7;
|
uint8_t start_bit = fu_header >> 7;
|
||||||
uint8_t av_unused end_bit = (fu_header & 0x40) >> 6;
|
uint8_t av_unused end_bit = (fu_header & 0x40) >> 6;
|
||||||
uint8_t nal_type = (fu_header & 0x1f);
|
uint8_t nal_type = fu_header & 0x1f;
|
||||||
uint8_t reconstructed_nal;
|
uint8_t reconstructed_nal;
|
||||||
|
|
||||||
// Reconstruct this packet's true nal; only the data follows.
|
// Reconstruct this packet's true nal; only the data follows.
|
||||||
/* The original nal forbidden bit and NRI are stored in this
|
/* The original nal forbidden bit and NRI are stored in this
|
||||||
* packet's nal. */
|
* packet's nal. */
|
||||||
reconstructed_nal = fu_indicator & (0xe0);
|
reconstructed_nal = fu_indicator & 0xe0;
|
||||||
reconstructed_nal |= nal_type;
|
reconstructed_nal |= nal_type;
|
||||||
|
|
||||||
// skip the fu_header
|
// skip the fu_header
|
||||||
@ -355,12 +358,14 @@ static int parse_h264_sdp_line(AVFormatContext *s, int st_index,
|
|||||||
char *dst = buf1;
|
char *dst = buf1;
|
||||||
|
|
||||||
// remove the protocol identifier
|
// remove the protocol identifier
|
||||||
while (*p && *p == ' ') p++; // strip spaces.
|
while (*p && *p == ' ')
|
||||||
while (*p && *p != ' ') p++; // eat protocol identifier
|
p++; // strip spaces.
|
||||||
while (*p && *p == ' ') p++; // strip trailing spaces.
|
while (*p && *p != ' ')
|
||||||
while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1) {
|
p++; // eat protocol identifier
|
||||||
|
while (*p && *p == ' ')
|
||||||
|
p++; // strip trailing spaces.
|
||||||
|
while (*p && *p != '-' && (dst - buf1) < sizeof(buf1) - 1)
|
||||||
*dst++ = *p++;
|
*dst++ = *p++;
|
||||||
}
|
|
||||||
*dst = '\0';
|
*dst = '\0';
|
||||||
|
|
||||||
// a='framesize:96 320-240'
|
// a='framesize:96 320-240'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user