Merge commit 'ddf5fb71ee9c8b2d9a23c0f661a84896cd7050fc'

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

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

See: 6821a5a4ad
Merged-by: Michael Niedermayer <michaelni@gmx.at>
pull/86/head
Michael Niedermayer 10 years ago
commit d8ddac363e
  1. 8
      libavformat/rtpenc.c
  2. 28
      libavformat/rtpenc_hevc.c
  3. 6
      libavformat/sdp.c
  4. 4
      libavformat/version.h

@ -202,9 +202,11 @@ static int rtp_write_header(AVFormatContext *s1)
} }
break; break;
case AV_CODEC_ID_HEVC: case AV_CODEC_ID_HEVC:
if (st->codec->extradata_size > 21 && /* Only check for the standardized hvcC version of extradata, keeping
(st->codec->extradata[0] || st->codec->extradata[1] || * things simple and similar to the avcC/H264 case above, instead
st->codec->extradata[2] > 1)) { * 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; s->nal_length_size = (st->codec->extradata[21] & 0x03) + 1;
} }
break; break;

@ -19,29 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#include "avformat.h"
#include "avc.h" #include "avc.h"
#include "avformat.h"
#include "rtpenc.h" #include "rtpenc.h"
#define RTP_HEVC_HEADERS_SIZE 3 #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) static void nal_send(AVFormatContext *ctx, const uint8_t *buf, int len, int last_packet_of_frame)
{ {
RTPMuxContext *rtp_ctx = ctx->priv_data; 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; buf += 2;
len -= 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 */ /* complete and send current RTP packet */
memcpy(&rtp_ctx->buf[RTP_HEVC_HEADERS_SIZE], buf, rtp_payload_size); 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); 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; rtp_ctx->timestamp = rtp_ctx->cur_timestamp;
if (rtp_ctx->nal_length_size) 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 else
buf_ptr = ff_avc_find_startcode(frame_buf, buf_end); buf_ptr = ff_avc_find_startcode(frame_buf, buf_end);
/* find all NAL units and send them as separate packets */ /* find all NAL units and send them as separate packets */
while (buf_ptr < buf_end) { while (buf_ptr < buf_end) {
if (rtp_ctx->nal_length_size) { 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) if (!next_NAL_unit)
next_NAL_unit = buf_end; next_NAL_unit = buf_end;
buf_ptr += rtp_ctx->nal_length_size; buf_ptr += rtp_ctx->nal_length_size;
} else { } else {
while (!*(buf_ptr++)) ; while (!*(buf_ptr++))
;
next_NAL_unit = ff_avc_find_startcode(buf_ptr, buf_end); next_NAL_unit = ff_avc_find_startcode(buf_ptr, buf_end);
} }
/* send the next NAL unit */ /* 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,
payload_type, c->width, c->height); payload_type, c->width, c->height);
break; 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: case AV_CODEC_ID_MPEG4:
if (c->extradata_size) { if (c->extradata_size) {
config = extradata2config(c); config = extradata2config(c);

@ -30,8 +30,8 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 56 #define LIBAVFORMAT_VERSION_MAJOR 56
#define LIBAVFORMAT_VERSION_MINOR 4 #define LIBAVFORMAT_VERSION_MINOR 5
#define LIBAVFORMAT_VERSION_MICRO 103 #define LIBAVFORMAT_VERSION_MICRO 100
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \ LIBAVFORMAT_VERSION_MINOR, \

Loading…
Cancel
Save