Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  mpegvideo: drop unnecessary arguments to hpel_motion()
  mpegvideo: drop 'inline' from some functions
  nellymoserdec: drop support for s16 output.
  bmpdec: only initialize palette for pal8.
  build: Properly remove object files while cleaning
  flacdsp: arm optimised lpc filter
  compat/vsnprintf: return number of bytes required on truncation.

Merged-by: Michael Niedermayer <michaelni@gmx.at>
  • Loading branch information...
commit e80cbdbc57292a4687339f6a7d30e0dcff42f9e8 2 parents 744e442 + 2568646
Michael Niedermayer michaelni authored
3  common.mak
@@ -124,4 +124,7 @@ CLEANSUFFIXES = *.d *.o *~ *.h.c *.map *.ver *.ho *.gcno *.gcda
124 124 DISTCLEANSUFFIXES = *.pc
125 125 LIBSUFFIXES = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a
126 126
  127 +clean::
  128 + $(RM) $(OBJS) $(OBJS:.o=.d)
  129 +
127 130 -include $(wildcard $(OBJS:.o=.d) $(HOSTOBJS:.o=.d) $(TESTOBJS:.o=.d) $(HOBJS:.o=.d))
3  libavcodec/arm/Makefile
@@ -8,6 +8,9 @@ OBJS-$(CONFIG_DCA_DECODER) += arm/dcadsp_init_arm.o \
8 8
9 9 ARMV6-OBJS-$(CONFIG_AC3DSP) += arm/ac3dsp_armv6.o
10 10
  11 +OBJS-$(CONFIG_FLAC_DECODER) += arm/flacdsp_init_arm.o \
  12 + arm/flacdsp_arm.o \
  13 +
11 14 OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o
12 15 ARMV6-OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_fixed_armv6.o
13 16
146 libavcodec/arm/flacdsp_arm.S
... ... @@ -0,0 +1,146 @@
  1 +/*
  2 + * Copyright (c) 2012 Mans Rullgard <mans@mansr.com>
  3 + *
  4 + * This file is part of FFmpeg
  5 + *
  6 + * FFmpeg is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU Lesser General Public
  8 + * License as published by the Free Software Foundation; either
  9 + * version 2.1 of the License, or (at your option) any later version.
  10 + *
  11 + * FFmpeg is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14 + * Lesser General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public
  17 + * License along with FFmpeg; if not, write to the Free Software
  18 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19 + */
  20 +
  21 +#include "libavutil/arm/asm.S"
  22 +
  23 +function flac_lpc_16_1_arm
  24 + ldr r12, [sp]
  25 + push {r4, lr}
  26 + ldr r1, [r1]
  27 + subs r12, r12, #2
  28 + ldr lr, [r0], #4
  29 + beq 2f
  30 + it lt
  31 + poplt {r4, pc}
  32 +1:
  33 + mul r4, lr, r1
  34 + ldm r0, {r2, lr}
  35 + add_sh r2, r2, r4, asr r3
  36 + mul r4, r2, r1
  37 + subs r12, r12, #2
  38 + add_sh lr, lr, r4, asr r3
  39 + stm r0!, {r2, lr}
  40 + bgt 1b
  41 + it lt
  42 + poplt {r4, pc}
  43 +2:
  44 + mul r4, lr, r1
  45 + ldr r2, [r0]
  46 + add_sh r2, r2, r4, asr r3
  47 + str r2, [r0]
  48 + pop {r4, pc}
  49 +endfunc
  50 +
  51 +function flac_lpc_16_2_arm
  52 + ldr r12, [sp]
  53 + subs r12, r12, r2
  54 + it le
  55 + bxle lr
  56 +
  57 + push {r4-r9, lr}
  58 + ldm r0!, {r6, r7}
  59 + ldm r1, {r8, r9}
  60 + subs r12, r12, #1
  61 + beq 2f
  62 +1:
  63 + mul r4, r6, r8
  64 + mul r5, r7, r8
  65 + mla r4, r7, r9, r4
  66 + ldm r0, {r6, r7}
  67 + add_sh r6, r6, r4, asr r3
  68 + mla r5, r6, r9, r5
  69 + add_sh r7, r7, r5, asr r3
  70 + stm r0!, {r6, r7}
  71 + subs r12, r12, #2
  72 + bgt 1b
  73 + it lt
  74 + poplt {r4-r9, pc}
  75 +2:
  76 + mul r4, r6, r8
  77 + mla r4, r7, r9, r4
  78 + ldr r5, [r0]
  79 + add_sh r5, r5, r4, asr r3
  80 + str r5, [r0]
  81 + pop {r4-r9, pc}
  82 +endfunc
  83 +
  84 +function ff_flac_lpc_16_arm, export=1
  85 + cmp r2, #2
  86 + blt flac_lpc_16_1_arm
  87 + beq flac_lpc_16_2_arm
  88 +
  89 + ldr r12, [sp]
  90 + subs r12, r12, r2
  91 + it le
  92 + bxle lr
  93 +
  94 + push {r4-r9, lr}
  95 +
  96 + subs r12, r12, #1
  97 + beq 3f
  98 +1:
  99 + sub lr, r2, #2
  100 + mov r4, #0
  101 + mov r5, #0
  102 +
  103 + ldr r7, [r0], #4
  104 + ldr r9, [r1], #4
  105 +2:
  106 + mla r4, r7, r9, r4
  107 + ldm r0!, {r6, r7}
  108 + mla r5, r6, r9, r5
  109 + ldm r1!, {r8, r9}
  110 + mla r4, r6, r8, r4
  111 + subs lr, lr, #2
  112 + mla r5, r7, r8, r5
  113 + bgt 2b
  114 + blt 6f
  115 +
  116 + mla r4, r7, r9, r4
  117 + ldr r7, [r0], #4
  118 + mla r5, r7, r9, r5
  119 + ldr r9, [r1], #4
  120 +6:
  121 + mla r4, r7, r9, r4
  122 + ldm r0, {r6, r7}
  123 + add_sh r6, r6, r4, asr r3
  124 + mla r5, r6, r9, r5
  125 + add_sh r7, r7, r5, asr r3
  126 + stm r0!, {r6, r7}
  127 + sub r0, r0, r2, lsl #2
  128 + sub r1, r1, r2, lsl #2
  129 +
  130 + subs r12, r12, #2
  131 + bgt 1b
  132 + it lt
  133 + poplt {r4-r9, pc}
  134 +3:
  135 + mov r4, #0
  136 +4:
  137 + ldr r5, [r1], #4
  138 + ldr r6, [r0], #4
  139 + mla r4, r5, r6, r4
  140 + subs r2, r2, #1
  141 + bgt 4b
  142 + ldr r5, [r0]
  143 + add_sh r5, r5, r4, asr r3
  144 + str r5, [r0]
  145 + pop {r4-r9, pc}
  146 +endfunc
32 libavcodec/arm/flacdsp_init_arm.c
... ... @@ -0,0 +1,32 @@
  1 +/*
  2 + * Copyright (c) 2012 Mans Rullgard <mans@mansr.com>
  3 + *
  4 + * This file is part of FFmpeg.
  5 + *
  6 + * FFmpeg is free software; you can redistribute it and/or
  7 + * modify it under the terms of the GNU Lesser General Public
  8 + * License as published by the Free Software Foundation; either
  9 + * version 2.1 of the License, or (at your option) any later version.
  10 + *
  11 + * FFmpeg is distributed in the hope that it will be useful,
  12 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14 + * Lesser General Public License for more details.
  15 + *
  16 + * You should have received a copy of the GNU Lesser General Public
  17 + * License along with FFmpeg; if not, write to the Free Software
  18 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19 + */
  20 +
  21 +#include "libavcodec/flacdsp.h"
  22 +#include "config.h"
  23 +
  24 +void ff_flac_lpc_16_arm(int32_t *samples, const int coeffs[32], int order,
  25 + int qlevel, int len);
  26 +
  27 +av_cold void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt,
  28 + int bps)
  29 +{
  30 + if (bps <= 16)
  31 + c->lpc = ff_flac_lpc_16_arm;
  32 +}
6 libavcodec/bmp.c
@@ -232,9 +232,6 @@ static int bmp_decode_frame(AVCodecContext *avctx,
232 232 if(comp == BMP_RLE4 || comp == BMP_RLE8)
233 233 memset(p->data[0], 0, avctx->height * p->linesize[0]);
234 234
235   - if(depth == 4 || depth == 8)
236   - memset(p->data[1], 0, 1024);
237   -
238 235 if(height > 0){
239 236 ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
240 237 linesize = -p->linesize[0];
@@ -245,6 +242,9 @@ static int bmp_decode_frame(AVCodecContext *avctx,
245 242
246 243 if(avctx->pix_fmt == PIX_FMT_PAL8){
247 244 int colors = 1 << depth;
  245 +
  246 + memset(p->data[1], 0, 1024);
  247 +
248 248 if(ihsize >= 36){
249 249 int t;
250 250 buf = buf0 + 46;
4 libavcodec/flacdsp.c
@@ -21,6 +21,7 @@
21 21 #include "libavutil/attributes.h"
22 22 #include "libavutil/samplefmt.h"
23 23 #include "flacdsp.h"
  24 +#include "config.h"
24 25
25 26 #define SAMPLE_SIZE 16
26 27 #define PLANAR 0
@@ -119,4 +120,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt,
119 120 c->decorrelate[3] = flac_decorrelate_ms_c_16p;
120 121 break;
121 122 }
  123 +
  124 + if (ARCH_ARM)
  125 + ff_flacdsp_init_arm(c, fmt, bps);
122 126 }
1  libavcodec/flacdsp.h
@@ -30,5 +30,6 @@ typedef struct FLACDSPContext {
30 30 } FLACDSPContext;
31 31
32 32 void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
  33 +void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int bps);
33 34
34 35 #endif /* AVCODEC_FLACDSP_H */
62 libavcodec/mpegvideo_motion.c
@@ -30,9 +30,9 @@
30 30 #include "msmpeg4.h"
31 31 #include <limits.h>
32 32
33   -static inline void gmc1_motion(MpegEncContext *s,
34   - uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
35   - uint8_t **ref_picture)
  33 +static void gmc1_motion(MpegEncContext *s,
  34 + uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
  35 + uint8_t **ref_picture)
36 36 {
37 37 uint8_t *ptr;
38 38 int offset, src_x, src_y, linesize, uvlinesize;
@@ -116,9 +116,9 @@ static inline void gmc1_motion(MpegEncContext *s,
116 116 return;
117 117 }
118 118
119   -static inline void gmc_motion(MpegEncContext *s,
120   - uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
121   - uint8_t **ref_picture)
  119 +static void gmc_motion(MpegEncContext *s,
  120 + uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
  121 + uint8_t **ref_picture)
122 122 {
123 123 uint8_t *ptr;
124 124 int linesize, uvlinesize;
@@ -174,11 +174,8 @@ static inline void gmc_motion(MpegEncContext *s,
174 174
175 175 static inline int hpel_motion(MpegEncContext *s,
176 176 uint8_t *dest, uint8_t *src,
177   - int field_based, int field_select,
178 177 int src_x, int src_y,
179   - int width, int height, int stride,
180   - int h_edge_pos, int v_edge_pos,
181   - int w, int h, op_pixels_func *pix_op,
  178 + op_pixels_func *pix_op,
182 179 int motion_x, int motion_y)
183 180 {
184 181 int dxy;
@@ -189,26 +186,24 @@ static inline int hpel_motion(MpegEncContext *s,
189 186 src_y += motion_y >> 1;
190 187
191 188 /* WARNING: do no forget half pels */
192   - src_x = av_clip(src_x, -16, width); //FIXME unneeded for emu?
193   - if (src_x == width)
  189 + src_x = av_clip(src_x, -16, s->width); //FIXME unneeded for emu?
  190 + if (src_x == s->width)
194 191 dxy &= ~1;
195   - src_y = av_clip(src_y, -16, height);
196   - if (src_y == height)
  192 + src_y = av_clip(src_y, -16, s->height);
  193 + if (src_y == s->height)
197 194 dxy &= ~2;
198   - src += src_y * stride + src_x;
  195 + src += src_y * s->linesize + src_x;
199 196
200 197 if(s->unrestricted_mv && (s->flags&CODEC_FLAG_EMU_EDGE)){
201   - if( (unsigned)src_x > FFMAX(h_edge_pos - (motion_x&1) - w, 0)
202   - || (unsigned)src_y > FFMAX(v_edge_pos - (motion_y&1) - h, 0)){
203   - s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based,
204   - src_x, src_y<<field_based, h_edge_pos, s->v_edge_pos);
  198 + if( (unsigned)src_x > FFMAX(s->h_edge_pos - (motion_x&1) - 8, 0)
  199 + || (unsigned)src_y > FFMAX(s->v_edge_pos - (motion_y&1) - 8, 0)){
  200 + s->dsp.emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, 9, 9,
  201 + src_x, src_y, s->h_edge_pos, s->v_edge_pos);
205 202 src= s->edge_emu_buffer;
206 203 emu=1;
207 204 }
208 205 }
209   - if(field_select)
210   - src += s->linesize;
211   - pix_op[dxy](dest, src, stride, h);
  206 + pix_op[dxy](dest, src, s->linesize, 8);
212 207 return emu;
213 208 }
214 209
@@ -447,11 +442,9 @@ static inline void obmc_motion(MpegEncContext *s,
447 442 ptr[i]= ptr[MID];
448 443 }else{
449 444 ptr[i]= s->obmc_scratchpad + 8*(i&1) + s->linesize*8*(i>>1);
450   - hpel_motion(s, ptr[i], src, 0, 0,
  445 + hpel_motion(s, ptr[i], src,
451 446 src_x, src_y,
452   - s->width, s->height, s->linesize,
453   - s->h_edge_pos, s->v_edge_pos,
454   - 8, 8, pix_op,
  447 + pix_op,
455 448 mv[i][0], mv[i][1]);
456 449 }
457 450 }
@@ -554,11 +547,12 @@ static inline void qpel_motion(MpegEncContext *s,
554 547 /**
555 548 * h263 chroma 4mv motion compensation.
556 549 */
557   -static inline void chroma_4mv_motion(MpegEncContext *s,
558   - uint8_t *dest_cb, uint8_t *dest_cr,
559   - uint8_t **ref_picture,
560   - op_pixels_func *pix_op,
561   - int mx, int my){
  550 +static void chroma_4mv_motion(MpegEncContext *s,
  551 + uint8_t *dest_cb, uint8_t *dest_cr,
  552 + uint8_t **ref_picture,
  553 + op_pixels_func *pix_op,
  554 + int mx, int my)
  555 +{
562 556 int dxy, emu=0, src_x, src_y, offset;
563 557 uint8_t *ptr;
564 558
@@ -773,11 +767,9 @@ static av_always_inline void MPV_motion_internal(MpegEncContext *s,
773 767 }else{
774 768 for(i=0;i<4;i++) {
775 769 hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
776   - ref_picture[0], 0, 0,
  770 + ref_picture[0],
777 771 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
778   - s->width, s->height, s->linesize,
779   - s->h_edge_pos, s->v_edge_pos,
780   - 8, 8, pix_op[1],
  772 + pix_op[1],
781 773 s->mv[dir][i][0], s->mv[dir][i][1]);
782 774
783 775 mx += s->mv[dir][i][0];
31 libavcodec/nellymoserdec.c
@@ -48,13 +48,11 @@
48 48 typedef struct NellyMoserDecodeContext {
49 49 AVCodecContext* avctx;
50 50 AVFrame frame;
51   - float *float_buf;
52 51 AVLFG random_state;
53 52 GetBitContext gb;
54 53 float scale_bias;
55 54 DSPContext dsp;
56 55 FFTContext imdct_ctx;
57   - FmtConvertContext fmt_conv;
58 56 DECLARE_ALIGNED(32, float, imdct_buf)[2][NELLY_BUF_LEN];
59 57 float *imdct_out;
60 58 float *imdct_prev;
@@ -124,19 +122,8 @@ static av_cold int decode_init(AVCodecContext * avctx) {
124 122
125 123 ff_dsputil_init(&s->dsp, avctx);
126 124
127   - if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) {
128   - s->scale_bias = 1.0/(32768*8);
129   - avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
130   - } else {
131   - s->scale_bias = 1.0/(1*8);
132   - avctx->sample_fmt = AV_SAMPLE_FMT_S16;
133   - ff_fmt_convert_init(&s->fmt_conv, avctx);
134   - s->float_buf = av_mallocz(NELLY_SAMPLES * sizeof(*s->float_buf));
135   - if (!s->float_buf) {
136   - av_log(avctx, AV_LOG_ERROR, "error allocating float buffer\n");
137   - return AVERROR(ENOMEM);
138   - }
139   - }
  125 + s->scale_bias = 1.0/(32768*8);
  126 + avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
140 127
141 128 /* Generate overlap window */
142 129 if (!ff_sine_128[127])
@@ -158,7 +145,6 @@ static int decode_tag(AVCodecContext *avctx, void *data,
158 145 int buf_size = avpkt->size;
159 146 NellyMoserDecodeContext *s = avctx->priv_data;
160 147 int blocks, i, ret;
161   - int16_t *samples_s16;
162 148 float *samples_flt;
163 149
164 150 blocks = buf_size / NELLY_BLOCK_LEN;
@@ -188,18 +174,11 @@ static int decode_tag(AVCodecContext *avctx, void *data,
188 174 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
189 175 return ret;
190 176 }
191   - samples_s16 = (int16_t *)s->frame.data[0];
192 177 samples_flt = (float *)s->frame.data[0];
193 178
194 179 for (i=0 ; i<blocks ; i++) {
195   - if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
196   - nelly_decode_block(s, buf, samples_flt);
197   - samples_flt += NELLY_SAMPLES;
198   - } else {
199   - nelly_decode_block(s, buf, s->float_buf);
200   - s->fmt_conv.float_to_int16(samples_s16, s->float_buf, NELLY_SAMPLES);
201   - samples_s16 += NELLY_SAMPLES;
202   - }
  180 + nelly_decode_block(s, buf, samples_flt);
  181 + samples_flt += NELLY_SAMPLES;
203 182 buf += NELLY_BLOCK_LEN;
204 183 }
205 184
@@ -212,7 +191,6 @@ static int decode_tag(AVCodecContext *avctx, void *data,
212 191 static av_cold int decode_end(AVCodecContext * avctx) {
213 192 NellyMoserDecodeContext *s = avctx->priv_data;
214 193
215   - av_freep(&s->float_buf);
216 194 ff_mdct_end(&s->imdct_ctx);
217 195
218 196 return 0;
@@ -229,6 +207,5 @@ AVCodec ff_nellymoser_decoder = {
229 207 .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE,
230 208 .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
231 209 .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
232   - AV_SAMPLE_FMT_S16,
233 210 AV_SAMPLE_FMT_NONE },
234 211 };
6 libavutil/arm/asm.S
@@ -186,6 +186,12 @@ ELF .size \name, . - \name
186 186 #endif
187 187 .endm
188 188
  189 +.macro add_sh rd, rn, rm, sh:vararg
  190 +A add \rd, \rn, \rm, \sh
  191 +T mov \rm, \rm, \sh
  192 +T add \rd, \rn, \rm
  193 +.endm
  194 +
189 195 .macro ldr_pre rt, rn, rm:vararg
190 196 A ldr \rt, [\rn, \rm]!
191 197 T add \rn, \rn, \rm

0 comments on commit e80cbdb

Please sign in to comment.
Something went wrong with that request. Please try again.