Mercurial > libavcodec.hg
annotate sp5xdec.c @ 12510:ef2f2db5b7be libavcodec
Unroll loop in h264_idct_add8_sse2(). This means we can inline scan8[] in the
code directly also and remove loop setup. 20% faster in function, 0.8% overall.
See "[PATCH] unroll loop in h264_idct_add8_sse2()" thread on ML.
| author | rbultje |
|---|---|
| date | Fri, 24 Sep 2010 14:05:45 +0000 |
| parents | ce660f4bda0d |
| children |
| rev | line source |
|---|---|
| 5020 | 1 /* |
| 5042 | 2 * Sunplus JPEG decoder (SP5X) |
| 5020 | 3 * Copyright (c) 2003 Alex Beregszaszi |
| 4 * | |
| 5 * This file is part of FFmpeg. | |
| 6 * | |
| 7 * FFmpeg is free software; you can redistribute it and/or | |
| 8 * modify it under the terms of the GNU Lesser General Public | |
| 9 * License as published by the Free Software Foundation; either | |
| 10 * version 2.1 of the License, or (at your option) any later version. | |
| 11 * | |
| 12 * FFmpeg is distributed in the hope that it will be useful, | |
| 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 15 * Lesser General Public License for more details. | |
| 16 * | |
| 17 * You should have received a copy of the GNU Lesser General Public | |
| 18 * License along with FFmpeg; if not, write to the Free Software | |
| 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 20 */ | |
| 21 | |
| 22 /** | |
|
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11560
diff
changeset
|
23 * @file |
| 5042 | 24 * Sunplus JPEG decoder (SP5X). |
| 5020 | 25 */ |
| 26 | |
| 27 #include "avcodec.h" | |
| 28 #include "mjpeg.h" | |
| 5041 | 29 #include "mjpegdec.h" |
| 5042 | 30 #include "sp5x.h" |
| 5020 | 31 |
| 32 | |
| 33 static int sp5x_decode_frame(AVCodecContext *avctx, | |
| 34 void *data, int *data_size, | |
|
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
35 AVPacket *avpkt) |
| 5020 | 36 { |
|
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
37 const uint8_t *buf = avpkt->data; |
|
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
38 int buf_size = avpkt->size; |
|
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
39 AVPacket avpkt_recoded; |
| 5020 | 40 const int qscale = 5; |
| 9593 | 41 const uint8_t *buf_ptr; |
| 6221 | 42 uint8_t *recoded; |
| 5020 | 43 int i = 0, j = 0; |
| 44 | |
| 45 if (!avctx->width || !avctx->height) | |
| 46 return -1; | |
| 47 | |
| 48 buf_ptr = buf; | |
| 49 | |
| 50 recoded = av_mallocz(buf_size + 1024); | |
| 51 if (!recoded) | |
| 52 return -1; | |
| 53 | |
| 54 /* SOI */ | |
| 55 recoded[j++] = 0xFF; | |
| 56 recoded[j++] = 0xD8; | |
| 57 | |
| 58 memcpy(recoded+j, &sp5x_data_dqt[0], sizeof(sp5x_data_dqt)); | |
| 59 memcpy(recoded+j+5, &sp5x_quant_table[qscale * 2], 64); | |
| 60 memcpy(recoded+j+70, &sp5x_quant_table[(qscale * 2) + 1], 64); | |
| 61 j += sizeof(sp5x_data_dqt); | |
| 62 | |
| 63 memcpy(recoded+j, &sp5x_data_dht[0], sizeof(sp5x_data_dht)); | |
| 64 j += sizeof(sp5x_data_dht); | |
| 65 | |
| 66 memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof)); | |
| 5089 | 67 AV_WB16(recoded+j+5, avctx->coded_height); |
| 68 AV_WB16(recoded+j+7, avctx->coded_width); | |
| 5020 | 69 j += sizeof(sp5x_data_sof); |
| 70 | |
| 71 memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos)); | |
| 72 j += sizeof(sp5x_data_sos); | |
| 73 | |
| 5736 | 74 if(avctx->codec_id==CODEC_ID_AMV) |
| 75 for (i = 2; i < buf_size-2 && j < buf_size+1024-2; i++) | |
| 76 recoded[j++] = buf[i]; | |
| 77 else | |
| 5020 | 78 for (i = 14; i < buf_size && j < buf_size+1024-2; i++) |
| 79 { | |
| 80 recoded[j++] = buf[i]; | |
| 81 if (buf[i] == 0xff) | |
| 82 recoded[j++] = 0; | |
| 83 } | |
| 84 | |
| 85 /* EOI */ | |
| 86 recoded[j++] = 0xFF; | |
| 87 recoded[j++] = 0xD9; | |
| 88 | |
| 5818 | 89 avctx->flags &= ~CODEC_FLAG_EMU_EDGE; |
|
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
90 av_init_packet(&avpkt_recoded); |
|
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
91 avpkt_recoded.data = recoded; |
|
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
92 avpkt_recoded.size = j; |
|
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
8718
diff
changeset
|
93 i = ff_mjpeg_decode_frame(avctx, data, data_size, &avpkt_recoded); |
| 5020 | 94 |
| 95 av_free(recoded); | |
| 96 | |
| 97 return i; | |
| 98 } | |
| 99 | |
| 100 AVCodec sp5x_decoder = { | |
| 101 "sp5x", | |
|
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
9797
diff
changeset
|
102 AVMEDIA_TYPE_VIDEO, |
| 5020 | 103 CODEC_ID_SP5X, |
| 104 sizeof(MJpegDecodeContext), | |
| 5041 | 105 ff_mjpeg_decode_init, |
| 5020 | 106 NULL, |
| 5041 | 107 ff_mjpeg_decode_end, |
| 5020 | 108 sp5x_decode_frame, |
| 109 CODEC_CAP_DR1, | |
| 6710 | 110 NULL, |
|
12108
c35d7bc64882
Add new decoder property max_lowres and do not init decoder if requested value is higher.
cehoyos
parents:
11644
diff
changeset
|
111 .max_lowres = 5, |
|
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
112 .long_name = NULL_IF_CONFIG_SMALL("Sunplus JPEG (SP5X)"), |
| 5020 | 113 }; |
| 5736 | 114 |
| 115 AVCodec amv_decoder = { | |
| 116 "amv", | |
|
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
9797
diff
changeset
|
117 AVMEDIA_TYPE_VIDEO, |
| 5736 | 118 CODEC_ID_AMV, |
| 119 sizeof(MJpegDecodeContext), | |
| 120 ff_mjpeg_decode_init, | |
| 121 NULL, | |
| 122 ff_mjpeg_decode_end, | |
| 6710 | 123 sp5x_decode_frame, |
| 9797 | 124 CODEC_CAP_DR1, |
|
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6710
diff
changeset
|
125 .long_name = NULL_IF_CONFIG_SMALL("AMV Video"), |
| 5736 | 126 }; |
