avcodec/libx264: Simplify copying packet data
x264.h: "the payloads of all output NALs are guaranteed to be sequential in memory." Therefore we can omit the loop. Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -139,7 +139,6 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
|
|||||||
X264Context *x4 = ctx->priv_data;
|
X264Context *x4 = ctx->priv_data;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
uint64_t size = x4->sei_size;
|
uint64_t size = x4->sei_size;
|
||||||
int i;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!nnal)
|
if (!nnal)
|
||||||
@@ -165,14 +164,14 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt,
|
|||||||
if (x4->sei_size > 0) {
|
if (x4->sei_size > 0) {
|
||||||
memcpy(p, x4->sei, x4->sei_size);
|
memcpy(p, x4->sei, x4->sei_size);
|
||||||
p += x4->sei_size;
|
p += x4->sei_size;
|
||||||
|
size -= x4->sei_size;
|
||||||
x4->sei_size = 0;
|
x4->sei_size = 0;
|
||||||
av_freep(&x4->sei);
|
av_freep(&x4->sei);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nnal; i++){
|
/* x264 guarantees the payloads of the NALs
|
||||||
memcpy(p, nals[i].p_payload, nals[i].i_payload);
|
* to be sequential in memory. */
|
||||||
p += nals[i].i_payload;
|
memcpy(p, nals[0].p_payload, size);
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user