static av_cold int hevc_sdp_parse_fmtp_config(AVFormatContext *s,
AVStream *stream,
PayloadContext *hevc_data,
- char *attr, char *value)
+ const char *attr, const char *value)
{
/* profile-space: 0-3 */
/* profile-id: 0-31 */
if (!strcmp(attr, "profile-id")) {
hevc_data->profile_id = atoi(value);
- av_dlog(s, "SDP: found profile-id: %d\n", hevc_data->profile_id);
+ av_log(s, AV_LOG_TRACE, "SDP: found profile-id: %d\n", hevc_data->profile_id);
}
/* tier-flag: 0-1 */
if (!strcmp(attr, "sprop-max-don-diff")) {
if (atoi(value) > 0)
hevc_data->using_donl_field = 1;
- av_dlog(s, "Found sprop-max-don-diff in SDP, DON field usage is: %d\n",
+ av_log(s, AV_LOG_TRACE, "Found sprop-max-don-diff in SDP, DON field usage is: %d\n",
hevc_data->using_donl_field);
}
if (!strcmp(attr, "sprop-depack-buf-nalus")) {
if (atoi(value) > 0)
hevc_data->using_donl_field = 1;
- av_dlog(s, "Found sprop-depack-buf-nalus in SDP, DON field usage is: %d\n",
+ av_log(s, AV_LOG_TRACE, "Found sprop-depack-buf-nalus in SDP, DON field usage is: %d\n",
hevc_data->using_donl_field);
}
codec = current_stream->codec;
if (av_strstart(sdp_line_ptr, "framesize:", &sdp_line_ptr)) {
- char str_video_width[50];
- char *str_video_width_ptr = str_video_width;
-
- /*
- * parse "a=framesize:96 320-240"
- */
-
- /* ignore spaces */
- while (*sdp_line_ptr && *sdp_line_ptr == ' ')
- sdp_line_ptr++;
- /* ignore RTP payload ID */
- while (*sdp_line_ptr && *sdp_line_ptr != ' ')
- sdp_line_ptr++;
- /* ignore spaces */
- while (*sdp_line_ptr && *sdp_line_ptr == ' ')
- sdp_line_ptr++;
- /* extract the actual video resolution description */
- while (*sdp_line_ptr && *sdp_line_ptr != '-' &&
- (str_video_width_ptr - str_video_width) < sizeof(str_video_width) - 1)
- *str_video_width_ptr++ = *sdp_line_ptr++;
- /* add trailing zero byte */
- *str_video_width_ptr = '\0';
-
- /* determine the width value */
- codec->width = atoi(str_video_width);
- /* jump beyond the "-" and determine the height value */
- codec->height = atoi(sdp_line_ptr + 1);
+ ff_h264_parse_framesize(codec, sdp_line_ptr);
} else if (av_strstart(sdp_line_ptr, "fmtp:", &sdp_line_ptr)) {
int ret = ff_parse_fmtp(ctx, current_stream, hevc_data, sdp_line_ptr,
hevc_sdp_parse_fmtp_config);
codec->extradata_size = hevc_data->vps_size + hevc_data->sps_size +
hevc_data->pps_size + hevc_data->sei_size;
codec->extradata = av_malloc(codec->extradata_size +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ AV_INPUT_BUFFER_PADDING_SIZE);
if (!codec->extradata) {
ret = AVERROR(ENOMEM);
codec->extradata_size = 0;
pos += hevc_data->pps_size;
memcpy(codec->extradata + pos, hevc_data->sei, hevc_data->sei_size);
pos += hevc_data->sei_size;
- memset(codec->extradata + pos, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+ memset(codec->extradata + pos, 0, AV_INPUT_BUFFER_PADDING_SIZE);
}
av_freep(&hevc_data->vps);
}
/*
- decode the HEVC payload header according to section 4 of draft version 6:
-
- 0 1
- 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- |F| Type | LayerId | TID |
- +-------------+-----------------+
-
- Forbidden zero (F): 1 bit
- NAL unit type (Type): 6 bits
- NUH layer ID (LayerId): 6 bits
- NUH temporal ID plus 1 (TID): 3 bits
- */
+ * decode the HEVC payload header according to section 4 of draft version 6:
+ *
+ * 0 1
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * |F| Type | LayerId | TID |
+ * +-------------+-----------------+
+ *
+ * Forbidden zero (F): 1 bit
+ * NAL unit type (Type): 6 bits
+ * NUH layer ID (LayerId): 6 bits
+ * NUH temporal ID plus 1 (TID): 3 bits
+ */
nal_type = (buf[0] >> 1) & 0x3f;
lid = ((buf[0] << 5) & 0x20) | ((buf[1] >> 3) & 0x1f);
tid = buf[1] & 0x07;
case 39:
/* single NAL unit packet */
default:
- /* sanity check for size of input packet: 1 byte payload at least */
- if (len < 1) {
- av_log(ctx, AV_LOG_ERROR,
- "Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",
- len, nal_type);
- return AVERROR_INVALIDDATA;
- }
-
/* create A/V packet */
if ((res = av_new_packet(pkt, sizeof(start_sequence) + len)) < 0)
return res;
len -= RTP_HEVC_PAYLOAD_HEADER_SIZE;
/*
- decode the FU header
-
- 0 1 2 3 4 5 6 7
- +-+-+-+-+-+-+-+-+
- |S|E| FuType |
- +---------------+
-
- Start fragment (S): 1 bit
- End fragment (E): 1 bit
- FuType: 6 bits
- */
+ * decode the FU header
+ *
+ * 0 1 2 3 4 5 6 7
+ * +-+-+-+-+-+-+-+-+
+ * |S|E| FuType |
+ * +---------------+
+ *
+ * Start fragment (S): 1 bit
+ * End fragment (E): 1 bit
+ * FuType: 6 bits
+ */
first_fragment = buf[0] & 0x80;
last_fragment = buf[0] & 0x40;
fu_type = buf[0] & 0x3f;
len -= RTP_HEVC_DONL_FIELD_SIZE;
}
- av_dlog(ctx, " FU type %d with %d bytes\n", fu_type, len);
-
- if (len > 0) {
- new_nal_header[0] = (rtp_pl[0] & 0x81) | (fu_type << 1);
- new_nal_header[1] = rtp_pl[1];
-
- /* start fragment vs. subsequent fragments */
- if (first_fragment) {
- if (!last_fragment) {
- /* create A/V packet which is big enough */
- if ((res = av_new_packet(pkt, sizeof(start_sequence) + sizeof(new_nal_header) + len)) < 0)
- return res;
- /* A/V packet: copy start sequence */
- memcpy(pkt->data, start_sequence, sizeof(start_sequence));
- /* A/V packet: copy new NAL header */
- memcpy(pkt->data + sizeof(start_sequence), new_nal_header, sizeof(new_nal_header));
- /* A/V packet: copy NAL unit data */
- memcpy(pkt->data + sizeof(start_sequence) + sizeof(new_nal_header), buf, len);
- } else {
- av_log(ctx, AV_LOG_ERROR, "Illegal combination of S and E bit in RTP/HEVC packet\n");
- res = AVERROR_INVALIDDATA;
- }
- } else {
- /* create A/V packet */
- if ((res = av_new_packet(pkt, len)) < 0)
- return res;
- /* A/V packet: copy NAL unit data */
- memcpy(pkt->data, buf, len);
- }
- } else {
+ av_log(ctx, AV_LOG_TRACE, " FU type %d with %d bytes\n", fu_type, len);
+
+ if (len <= 0) {
/* sanity check for size of input packet: 1 byte payload at least */
av_log(ctx, AV_LOG_ERROR,
"Too short RTP/HEVC packet, got %d bytes of NAL unit type %d\n",
len, nal_type);
- res = AVERROR_INVALIDDATA;
+ return AVERROR_INVALIDDATA;
}
+ if (first_fragment && last_fragment) {
+ av_log(ctx, AV_LOG_ERROR, "Illegal combination of S and E bit in RTP/HEVC packet\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ new_nal_header[0] = (rtp_pl[0] & 0x81) | (fu_type << 1);
+ new_nal_header[1] = rtp_pl[1];
+
+ res = ff_h264_handle_frag_packet(pkt, buf, len, first_fragment,
+ new_nal_header, sizeof(new_nal_header));
+
break;
/* PACI packet */
case 50: