From: Hendrik Leppkes Date: Thu, 22 Oct 2015 18:31:09 +0000 (+0200) Subject: Merge commit '48c06386831604921bdaf4fb77ea02766cd615f4' X-Git-Tag: android-x86-7.1-r1~8355 X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=8fe1433ad4f866df58c0862f0d13535c96e90d63;p=android-x86%2Fexternal-ffmpeg.git Merge commit '48c06386831604921bdaf4fb77ea02766cd615f4' * commit '48c06386831604921bdaf4fb77ea02766cd615f4': dpx: Replace avpicture functions with imgutils Merged-by: Hendrik Leppkes --- 8fe1433ad4f866df58c0862f0d13535c96e90d63 diff --cc libavcodec/dpxenc.c index 9f3cbbe977,adcb529445..52e1ef2332 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@@ -75,22 -66,20 +75,23 @@@ static av_cold int encode_init(AVCodecC return 0; } -#define write16(p, value) \ -do { \ - if (s->big_endian) AV_WB16(p, value); \ - else AV_WL16(p, value); \ -} while(0) +static av_always_inline void write16_internal(int big_endian, void *p, int value) +{ + if (big_endian) AV_WB16(p, value); + else AV_WL16(p, value); +} + +static av_always_inline void write32_internal(int big_endian, void *p, int value) +{ + if (big_endian) AV_WB32(p, value); + else AV_WL32(p, value); +} -#define write32(p, value) \ -do { \ - if (s->big_endian) AV_WB32(p, value); \ - else AV_WL32(p, value); \ -} while(0) +#define write16(p, value) write16_internal(s->big_endian, p, value) +#define write32(p, value) write32_internal(s->big_endian, p, value) - static void encode_rgb48_10bit(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) + static void encode_rgb48_10bit(AVCodecContext *avctx, const AVFrame *pic, + uint8_t *dst) { DPXContext *s = avctx->priv_data; const uint8_t *src = pic->data[0]; @@@ -115,63 -104,6 +116,63 @@@ } } - static void encode_gbrp10(AVCodecContext *avctx, const AVPicture *pic, uint8_t *dst) ++static void encode_gbrp10(AVCodecContext *avctx, const AVFrame *pic, uint8_t *dst) +{ + DPXContext *s = avctx->priv_data; + const uint8_t *src[3] = {pic->data[0], pic->data[1], pic->data[2]}; + int x, y, i; + + for (y = 0; y < avctx->height; y++) { + for (x = 0; x < avctx->width; x++) { + int value; + if (s->big_endian) { + value = (AV_RB16(src[0] + 2*x) << 12) + | (AV_RB16(src[1] + 2*x) << 2) + | ((unsigned)AV_RB16(src[2] + 2*x) << 22); + } else { + value = (AV_RL16(src[0] + 2*x) << 12) + | (AV_RL16(src[1] + 2*x) << 2) + | ((unsigned)AV_RL16(src[2] + 2*x) << 22); + } + write32(dst, value); + dst += 4; + } + for (i = 0; i < 3; i++) + src[i] += pic->linesize[i]; + } +} + - static void encode_gbrp12(AVCodecContext *avctx, const AVPicture *pic, uint16_t *dst) ++static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint16_t *dst) +{ + DPXContext *s = avctx->priv_data; + const uint16_t *src[3] = {(uint16_t*)pic->data[0], + (uint16_t*)pic->data[1], + (uint16_t*)pic->data[2]}; + int x, y, i, pad; + pad = avctx->width*6; + pad = (FFALIGN(pad, 4) - pad) >> 1; + for (y = 0; y < avctx->height; y++) { + for (x = 0; x < avctx->width; x++) { + uint16_t value[3]; + if (s->big_endian) { + value[1] = AV_RB16(src[0] + x) << 4; + value[2] = AV_RB16(src[1] + x) << 4; + value[0] = AV_RB16(src[2] + x) << 4; + } else { + value[1] = AV_RL16(src[0] + x) << 4; + value[2] = AV_RL16(src[1] + x) << 4; + value[0] = AV_RL16(src[2] + x) << 4; + } + for (i = 0; i < 3; i++) + write16(dst++, value[i]); + } + for (i = 0; i < pad; i++) + *dst++ = 0; + for (i = 0; i < 3; i++) + src[i] += pic->linesize[i]/2; + } +} + static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { @@@ -228,36 -151,19 +229,37 @@@ write32(buf + 1628, avctx->sample_aspect_ratio.num); write32(buf + 1632, avctx->sample_aspect_ratio.den); - switch (s->bits_per_component) { + switch(s->bits_per_component) { case 8: case 16: - size = av_image_copy_to_buffer(buf + HEADER_SIZE, - pkt->size - HEADER_SIZE, - frame->data, frame->linesize, - avctx->pix_fmt, - avctx->width, avctx->height, 1); + if (need_align) { + int j; + const uint8_t *src = frame->data[0]; + uint8_t *dst = pkt->data + HEADER_SIZE; + size = (len + need_align) * avctx->height; + for (j=0; jheight; j++) { + memcpy(dst, src, len); + memset(dst + len, 0, need_align); + dst += len + need_align; + src += frame->linesize[0]; + } + } else { - size = avpicture_layout((const AVPicture*)frame, avctx->pix_fmt, - avctx->width, avctx->height, - buf + HEADER_SIZE, pkt->size - HEADER_SIZE); ++ size = av_image_copy_to_buffer(buf + HEADER_SIZE, pkt->size - HEADER_SIZE, ++ frame->data, frame->linesize, ++ avctx->pix_fmt, ++ avctx->width, avctx->height, 1); + } if (size < 0) return size; break; case 10: - encode_rgb48_10bit(avctx, frame, buf + HEADER_SIZE); + if (s->planar) - encode_gbrp10(avctx, (const AVPicture*)frame, buf + HEADER_SIZE); ++ encode_gbrp10(avctx, frame, buf + HEADER_SIZE); + else - encode_rgb48_10bit(avctx, (const AVPicture*)frame, buf + HEADER_SIZE); ++ encode_rgb48_10bit(avctx, frame, buf + HEADER_SIZE); + break; + case 12: - encode_gbrp12(avctx, (const AVPicture*)frame, (uint16_t*)(buf + HEADER_SIZE)); ++ encode_gbrp12(avctx, frame, (uint16_t*)(buf + HEADER_SIZE)); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n", s->bits_per_component);