@ -23,6 +23,7 @@
# include "libavutil/intreadwrite.h"
# include "libavutil/intreadwrite.h"
# include "libavutil/imgutils.h"
# include "libavutil/imgutils.h"
# include "avcodec.h"
# include "avcodec.h"
# include "encode.h"
# include "internal.h"
# include "internal.h"
typedef struct DPXContext {
typedef struct DPXContext {
@ -142,7 +143,7 @@ static void encode_gbrp10(AVCodecContext *avctx, const AVFrame *pic, uint8_t *ds
}
}
}
}
static void encode_gbrp12 ( AVCodecContext * avctx , const AVFrame * pic , uint16 _t * dst )
static void encode_gbrp12 ( AVCodecContext * avctx , const AVFrame * pic , uint8 _t * dst )
{
{
DPXContext * s = avctx - > priv_data ;
DPXContext * s = avctx - > priv_data ;
const uint16_t * src [ 3 ] = { ( uint16_t * ) pic - > data [ 0 ] ,
const uint16_t * src [ 3 ] = { ( uint16_t * ) pic - > data [ 0 ] ,
@ -163,11 +164,11 @@ static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint16_t *d
value [ 2 ] = AV_RL16 ( src [ 1 ] + x ) < < 4 ;
value [ 2 ] = AV_RL16 ( src [ 1 ] + x ) < < 4 ;
value [ 0 ] = AV_RL16 ( src [ 2 ] + x ) < < 4 ;
value [ 0 ] = AV_RL16 ( src [ 2 ] + x ) < < 4 ;
}
}
for ( i = 0 ; i < 3 ; i + + )
for ( i = 0 ; i < 3 ; i + + , dst + = 2 )
write16 ( dst + + , value [ i ] ) ;
write16 ( dst , value [ i ] ) ;
}
}
for ( i = 0 ; i < pad ; i + + )
for ( i = 0 ; i < pad ; i + + , dst + = 2 )
* dst + + = 0 ;
AV_WN16 ( dst , 0 ) ;
for ( i = 0 ; i < 3 ; i + + )
for ( i = 0 ; i < 3 ; i + + )
src [ i ] + = pic - > linesize [ i ] / 2 ;
src [ i ] + = pic - > linesize [ i ] / 2 ;
}
}
@ -196,7 +197,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
need_align = size - len ;
need_align = size - len ;
size * = avctx - > height ;
size * = avctx - > height ;
}
}
if ( ( ret = ff_alloc_packet2 ( avctx , pkt , size + HEADER_SIZE , 0 ) ) < 0 )
if ( ( ret = ff_get_encode_buffer ( avctx , pkt , size + HEADER_SIZE , 0 ) ) < 0 )
return ret ;
return ret ;
buf = pkt - > data ;
buf = pkt - > data ;
@ -259,7 +260,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
encode_rgb48_10bit ( avctx , frame , buf + HEADER_SIZE ) ;
encode_rgb48_10bit ( avctx , frame , buf + HEADER_SIZE ) ;
break ;
break ;
case 12 :
case 12 :
encode_gbrp12 ( avctx , frame , ( uint16_t * ) ( buf + HEADER_SIZE ) ) ;
encode_gbrp12 ( avctx , frame , 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 ) ;
@ -281,6 +282,7 @@ const AVCodec ff_dpx_encoder = {
. long_name = NULL_IF_CONFIG_SMALL ( " DPX (Digital Picture Exchange) image " ) ,
. long_name = NULL_IF_CONFIG_SMALL ( " DPX (Digital Picture Exchange) image " ) ,
. type = AVMEDIA_TYPE_VIDEO ,
. type = AVMEDIA_TYPE_VIDEO ,
. id = AV_CODEC_ID_DPX ,
. id = AV_CODEC_ID_DPX ,
. capabilities = AV_CODEC_CAP_DR1 ,
. priv_data_size = sizeof ( DPXContext ) ,
. priv_data_size = sizeof ( DPXContext ) ,
. init = encode_init ,
. init = encode_init ,
. encode2 = encode_frame ,
. encode2 = encode_frame ,