mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
dpxenc: switch to encode2().
This commit is contained in:
parent
83c7fe3245
commit
b3566a6a39
@ -22,6 +22,7 @@
|
|||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavutil/imgutils.h"
|
#include "libavutil/imgutils.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct DPXContext {
|
typedef struct DPXContext {
|
||||||
AVFrame picture;
|
AVFrame picture;
|
||||||
@ -99,15 +100,23 @@ static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
int buf_size, void *data)
|
const AVFrame *frame, int *got_packet)
|
||||||
{
|
{
|
||||||
DPXContext *s = avctx->priv_data;
|
DPXContext *s = avctx->priv_data;
|
||||||
int size;
|
int size, ret;
|
||||||
|
uint8_t *buf;
|
||||||
|
|
||||||
#define HEADER_SIZE 1664 /* DPX Generic header */
|
#define HEADER_SIZE 1664 /* DPX Generic header */
|
||||||
if (buf_size < HEADER_SIZE)
|
if (s->bits_per_component == 10)
|
||||||
return -1;
|
size = avctx->height * avctx->width * 4;
|
||||||
|
else
|
||||||
|
size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
|
||||||
|
if ((ret = ff_alloc_packet(pkt, size + HEADER_SIZE)) < 0) {
|
||||||
|
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
buf = pkt->data;
|
||||||
|
|
||||||
memset(buf, 0, HEADER_SIZE);
|
memset(buf, 0, HEADER_SIZE);
|
||||||
|
|
||||||
@ -138,17 +147,14 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
|||||||
switch (s->bits_per_component) {
|
switch (s->bits_per_component) {
|
||||||
case 8:
|
case 8:
|
||||||
case 16:
|
case 16:
|
||||||
size = avpicture_layout(data, avctx->pix_fmt,
|
size = avpicture_layout((const AVPicture*)frame, avctx->pix_fmt,
|
||||||
avctx->width, avctx->height,
|
avctx->width, avctx->height,
|
||||||
buf + HEADER_SIZE, buf_size - HEADER_SIZE);
|
buf + HEADER_SIZE, pkt->size - HEADER_SIZE);
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return size;
|
return size;
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
size = avctx->height * avctx->width * 4;
|
encode_rgb48_10bit(avctx, (const AVPicture*)frame, buf + HEADER_SIZE);
|
||||||
if (buf_size < HEADER_SIZE + size)
|
|
||||||
return -1;
|
|
||||||
encode_rgb48_10bit(avctx, data, buf + HEADER_SIZE);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n", s->bits_per_component);
|
av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n", s->bits_per_component);
|
||||||
@ -158,7 +164,11 @@ static int encode_frame(AVCodecContext *avctx, unsigned char *buf,
|
|||||||
size += HEADER_SIZE;
|
size += HEADER_SIZE;
|
||||||
|
|
||||||
write32(buf + 16, size); /* file size */
|
write32(buf + 16, size); /* file size */
|
||||||
return size;
|
|
||||||
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
|
*got_packet = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AVCodec ff_dpx_encoder = {
|
AVCodec ff_dpx_encoder = {
|
||||||
@ -167,7 +177,7 @@ AVCodec ff_dpx_encoder = {
|
|||||||
.id = CODEC_ID_DPX,
|
.id = CODEC_ID_DPX,
|
||||||
.priv_data_size = sizeof(DPXContext),
|
.priv_data_size = sizeof(DPXContext),
|
||||||
.init = encode_init,
|
.init = encode_init,
|
||||||
.encode = encode_frame,
|
.encode2 = encode_frame,
|
||||||
.pix_fmts = (const enum PixelFormat[]){
|
.pix_fmts = (const enum PixelFormat[]){
|
||||||
PIX_FMT_RGB24,
|
PIX_FMT_RGB24,
|
||||||
PIX_FMT_RGBA,
|
PIX_FMT_RGBA,
|
||||||
|
Loading…
Reference in New Issue
Block a user