Commit d8ddac36 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'ddf5fb71'

* commit 'ddf5fb71':
  rtpenc: HEVC/H.265 support

Conflicts:
	Changelog
	libavformat/rtpenc.c
	libavformat/rtpenc_hevc.c
	libavformat/version.h

See: 6821a5a4Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents b8d3f7fc ddf5fb71
......@@ -202,9 +202,11 @@ static int rtp_write_header(AVFormatContext *s1)
}
break;
case AV_CODEC_ID_HEVC:
if (st->codec->extradata_size > 21 &&
(st->codec->extradata[0] || st->codec->extradata[1] ||
st->codec->extradata[2] > 1)) {
/* Only check for the standardized hvcC version of extradata, keeping
* things simple and similar to the avcC/H264 case above, instead
* of trying to handle the pre-standardization versions (as in
* libavcodec/hevc.c). */
if (st->codec->extradata_size > 21 && st->codec->extradata[0] == 1) {
s->nal_length_size = (st->codec->extradata[21] & 0x03) + 1;
}
break;
......
......@@ -19,29 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avformat.h"
#include "avc.h"
#include "avformat.h"
#include "rtpenc.h"
#define RTP_HEVC_HEADERS_SIZE 3
static const uint8_t *avc_mp4_find_startcode(const uint8_t *start, const uint8_t *end, int nal_length_size)
{
unsigned int res = 0;
/* is the given data big enough for 1 NAL unit? */
if (end - start < nal_length_size)
return NULL;
while (nal_length_size--)
res = (res << 8) | *start++;
if (res > end - start)
return NULL;
return start + res;
}
static void nal_send(AVFormatContext *ctx, const uint8_t *buf, int len, int last_packet_of_frame)
{
RTPMuxContext *rtp_ctx = ctx->priv_data;
......@@ -90,7 +73,7 @@ static void nal_send(AVFormatContext *ctx, const uint8_t *buf, int len, int last
buf += 2;
len -= 2;
while (len + RTP_HEVC_HEADERS_SIZE > rtp_ctx->max_payload_size) {
while (len > rtp_payload_size) {
/* complete and send current RTP packet */
memcpy(&rtp_ctx->buf[RTP_HEVC_HEADERS_SIZE], buf, rtp_payload_size);
ff_rtp_send_data(ctx, rtp_ctx->buf, rtp_ctx->max_payload_size, 0);
......@@ -121,20 +104,21 @@ void ff_rtp_send_hevc(AVFormatContext *ctx, const uint8_t *frame_buf, int frame_
rtp_ctx->timestamp = rtp_ctx->cur_timestamp;
if (rtp_ctx->nal_length_size)
buf_ptr = avc_mp4_find_startcode(frame_buf, buf_end, rtp_ctx->nal_length_size) ? frame_buf : buf_end;
buf_ptr = ff_avc_mp4_find_startcode(frame_buf, buf_end, rtp_ctx->nal_length_size) ? frame_buf : buf_end;
else
buf_ptr = ff_avc_find_startcode(frame_buf, buf_end);
/* find all NAL units and send them as separate packets */
while (buf_ptr < buf_end) {
if (rtp_ctx->nal_length_size) {
next_NAL_unit = avc_mp4_find_startcode(buf_ptr, buf_end, rtp_ctx->nal_length_size);
next_NAL_unit = ff_avc_mp4_find_startcode(buf_ptr, buf_end, rtp_ctx->nal_length_size);
if (!next_NAL_unit)
next_NAL_unit = buf_end;
buf_ptr += rtp_ctx->nal_length_size;
} else {
while (!*(buf_ptr++)) ;
while (!*(buf_ptr++))
;
next_NAL_unit = ff_avc_find_startcode(buf_ptr, buf_end);
}
/* send the next NAL unit */
......
......@@ -428,6 +428,12 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
payload_type,
payload_type, c->width, c->height);
break;
case AV_CODEC_ID_HEVC:
if (c->extradata_size)
av_log(NULL, AV_LOG_WARNING, "HEVC extradata not currently "
"passed properly through SDP\n");
av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type);
break;
case AV_CODEC_ID_MPEG4:
if (c->extradata_size) {
config = extradata2config(c);
......
......@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 56
#define LIBAVFORMAT_VERSION_MINOR 4
#define LIBAVFORMAT_VERSION_MICRO 103
#define LIBAVFORMAT_VERSION_MINOR 5
#define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
......
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