* qatar/master: (27 commits)
asfdec: add side data to ASFStream packet instead of output packet.
idroqdec: set AVFMTCTX_NOHEADER and create streams as they occur.
nellymoserdec: Indicate that the decoder can handle changed parameters
libavcodec: Apply parameter change side data when decoding audio
flvdec: Add param change side data if the sample rate or channels have changed
libavformat: Add a utility function for adding parameter change side data
libavcodec: Define a side data type for parameter changes
aacdec: Handle new extradata passed as side data
flvdec: Export new AAC/H.264 extradata as side data on the next packet
libavcodec: Define a side data type for new extradata
flacdec: skip all track indices at once instead of looping.
mxf: Add PictureEssenceCoding UL for V210.
mxfdec: consider QuantizationBits between 17 and 24 to be pcm_s24*
mxfenc: Add support for MPEG-2 MP@HL-14 in mxf container.
mxf: H.264/MPEG-4 AVC Intra support
configure: Show whether the safe bitstream reader is enabled
x86: Tighten register constraints for decode_significance*_x86.
Replace Subversion revisions in comments by Git hashes.
h264_cabac: synchronize decode_significance_*_x86 conditionals
w32threads: wait for the waked thread in pthread_cond_signal.
...
Conflicts:
libavcodec/avcodec.h
libavcodec/version.h
libavformat/flvdec.c
libavformat/utils.c
tests/ref/lavfi/pixdesc
tests/ref/lavfi/pixfmts_copy
tests/ref/lavfi/pixfmts_null
tests/ref/lavfi/pixfmts_scale
tests/ref/lavfi/pixfmts_vflip
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -3311,6 +3311,7 @@ elif enabled gcc; then |
| 3311 | 3311 |
check_cflags -fno-tree-vectorize |
| 3312 | 3312 |
check_cflags -Werror=implicit-function-declaration |
| 3313 | 3313 |
check_cflags -Werror=missing-prototypes |
| 3314 |
+ check_cflags -Werror=declaration-after-statement |
|
| 3314 | 3315 |
elif enabled llvm_gcc; then |
| 3315 | 3316 |
check_cflags -mllvm -stack-alignment=16 |
| 3316 | 3317 |
elif enabled clang; then |
| ... | ... |
@@ -3406,6 +3407,7 @@ echo "postprocessing support ${postproc-no}"
|
| 3406 | 3406 |
echo "new filter support ${avfilter-no}"
|
| 3407 | 3407 |
echo "network support ${network-no}"
|
| 3408 | 3408 |
echo "threading support ${thread_type-no}"
|
| 3409 |
+echo "safe bitstream reader ${safe_bitstream_reader-no}"
|
|
| 3409 | 3410 |
echo "SDL support ${sdl-no}"
|
| 3410 | 3411 |
echo "Sun medialib support ${mlib-no}"
|
| 3411 | 3412 |
echo "libdxva2 enabled ${dxva2-no}"
|
| ... | ... |
@@ -722,16 +722,13 @@ static void decode_ltp(AACContext *ac, LongTermPrediction *ltp, |
| 722 | 722 |
|
| 723 | 723 |
/** |
| 724 | 724 |
* Decode Individual Channel Stream info; reference: table 4.6. |
| 725 |
- * |
|
| 726 |
- * @param common_window Channels have independent [0], or shared [1], Individual Channel Stream information. |
|
| 727 | 725 |
*/ |
| 728 | 726 |
static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, |
| 729 |
- GetBitContext *gb, int common_window) |
|
| 727 |
+ GetBitContext *gb) |
|
| 730 | 728 |
{
|
| 731 | 729 |
if (get_bits1(gb)) {
|
| 732 | 730 |
av_log(ac->avctx, AV_LOG_ERROR, "Reserved bit set.\n"); |
| 733 |
- memset(ics, 0, sizeof(IndividualChannelStream)); |
|
| 734 |
- return -1; |
|
| 731 |
+ return AVERROR_INVALIDDATA; |
|
| 735 | 732 |
} |
| 736 | 733 |
ics->window_sequence[1] = ics->window_sequence[0]; |
| 737 | 734 |
ics->window_sequence[0] = get_bits(gb, 2); |
| ... | ... |
@@ -766,13 +763,11 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, |
| 766 | 766 |
if (ics->predictor_present) {
|
| 767 | 767 |
if (ac->m4ac.object_type == AOT_AAC_MAIN) {
|
| 768 | 768 |
if (decode_prediction(ac, ics, gb)) {
|
| 769 |
- memset(ics, 0, sizeof(IndividualChannelStream)); |
|
| 770 |
- return -1; |
|
| 769 |
+ return AVERROR_INVALIDDATA; |
|
| 771 | 770 |
} |
| 772 | 771 |
} else if (ac->m4ac.object_type == AOT_AAC_LC) {
|
| 773 | 772 |
av_log(ac->avctx, AV_LOG_ERROR, "Prediction is not allowed in AAC-LC.\n"); |
| 774 |
- memset(ics, 0, sizeof(IndividualChannelStream)); |
|
| 775 |
- return -1; |
|
| 773 |
+ return AVERROR_INVALIDDATA; |
|
| 776 | 774 |
} else {
|
| 777 | 775 |
if ((ics->ltp.present = get_bits(gb, 1))) |
| 778 | 776 |
decode_ltp(ac, &ics->ltp, gb, ics->max_sfb); |
| ... | ... |
@@ -784,8 +779,7 @@ static int decode_ics_info(AACContext *ac, IndividualChannelStream *ics, |
| 784 | 784 |
av_log(ac->avctx, AV_LOG_ERROR, |
| 785 | 785 |
"Number of scalefactor bands in group (%d) exceeds limit (%d).\n", |
| 786 | 786 |
ics->max_sfb, ics->num_swb); |
| 787 |
- memset(ics, 0, sizeof(IndividualChannelStream)); |
|
| 788 |
- return -1; |
|
| 787 |
+ return AVERROR_INVALIDDATA; |
|
| 789 | 788 |
} |
| 790 | 789 |
|
| 791 | 790 |
return 0; |
| ... | ... |
@@ -1390,8 +1384,8 @@ static int decode_ics(AACContext *ac, SingleChannelElement *sce, |
| 1390 | 1390 |
global_gain = get_bits(gb, 8); |
| 1391 | 1391 |
|
| 1392 | 1392 |
if (!common_window && !scale_flag) {
|
| 1393 |
- if (decode_ics_info(ac, ics, gb, 0) < 0) |
|
| 1394 |
- return -1; |
|
| 1393 |
+ if (decode_ics_info(ac, ics, gb) < 0) |
|
| 1394 |
+ return AVERROR_INVALIDDATA; |
|
| 1395 | 1395 |
} |
| 1396 | 1396 |
|
| 1397 | 1397 |
if (decode_band_types(ac, sce->band_type, sce->band_type_run_end, gb, ics) < 0) |
| ... | ... |
@@ -1507,8 +1501,8 @@ static int decode_cpe(AACContext *ac, GetBitContext *gb, ChannelElement *cpe) |
| 1507 | 1507 |
|
| 1508 | 1508 |
common_window = get_bits1(gb); |
| 1509 | 1509 |
if (common_window) {
|
| 1510 |
- if (decode_ics_info(ac, &cpe->ch[0].ics, gb, 1)) |
|
| 1511 |
- return -1; |
|
| 1510 |
+ if (decode_ics_info(ac, &cpe->ch[0].ics, gb)) |
|
| 1511 |
+ return AVERROR_INVALIDDATA; |
|
| 1512 | 1512 |
i = cpe->ch[1].ics.use_kb_window[0]; |
| 1513 | 1513 |
cpe->ch[1].ics = cpe->ch[0].ics; |
| 1514 | 1514 |
cpe->ch[1].ics.use_kb_window[1] = i; |
| ... | ... |
@@ -2282,12 +2276,31 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data, |
| 2282 | 2282 |
static int aac_decode_frame(AVCodecContext *avctx, void *data, |
| 2283 | 2283 |
int *got_frame_ptr, AVPacket *avpkt) |
| 2284 | 2284 |
{
|
| 2285 |
+ AACContext *ac = avctx->priv_data; |
|
| 2285 | 2286 |
const uint8_t *buf = avpkt->data; |
| 2286 | 2287 |
int buf_size = avpkt->size; |
| 2287 | 2288 |
GetBitContext gb; |
| 2288 | 2289 |
int buf_consumed; |
| 2289 | 2290 |
int buf_offset; |
| 2290 | 2291 |
int err; |
| 2292 |
+ int new_extradata_size; |
|
| 2293 |
+ const uint8_t *new_extradata = av_packet_get_side_data(avpkt, |
|
| 2294 |
+ AV_PKT_DATA_NEW_EXTRADATA, |
|
| 2295 |
+ &new_extradata_size); |
|
| 2296 |
+ |
|
| 2297 |
+ if (new_extradata) {
|
|
| 2298 |
+ av_free(avctx->extradata); |
|
| 2299 |
+ avctx->extradata = av_mallocz(new_extradata_size + |
|
| 2300 |
+ FF_INPUT_BUFFER_PADDING_SIZE); |
|
| 2301 |
+ if (!avctx->extradata) |
|
| 2302 |
+ return AVERROR(ENOMEM); |
|
| 2303 |
+ avctx->extradata_size = new_extradata_size; |
|
| 2304 |
+ memcpy(avctx->extradata, new_extradata, new_extradata_size); |
|
| 2305 |
+ if (decode_audio_specific_config(ac, ac->avctx, &ac->m4ac, |
|
| 2306 |
+ avctx->extradata, |
|
| 2307 |
+ avctx->extradata_size*8, 1) < 0) |
|
| 2308 |
+ return AVERROR_INVALIDDATA; |
|
| 2309 |
+ } |
|
| 2291 | 2310 |
|
| 2292 | 2311 |
init_get_bits(&gb, buf, buf_size * 8); |
| 2293 | 2312 |
|
| ... | ... |
@@ -792,6 +792,10 @@ typedef struct RcOverride{
|
| 792 | 792 |
*/ |
| 793 | 793 |
#define CODEC_CAP_SLICE_THREADS 0x2000 |
| 794 | 794 |
/** |
| 795 |
+ * Codec supports changed parameters at any point. |
|
| 796 |
+ */ |
|
| 797 |
+#define CODEC_CAP_PARAM_CHANGE 0x4000 |
|
| 798 |
+/** |
|
| 795 | 799 |
* Codec is lossless. |
| 796 | 800 |
*/ |
| 797 | 801 |
#define CODEC_CAP_LOSSLESS 0x80000000 |
| ... | ... |
@@ -877,6 +881,8 @@ typedef struct AVPanScan{
|
| 877 | 877 |
|
| 878 | 878 |
enum AVPacketSideDataType {
|
| 879 | 879 |
AV_PKT_DATA_PALETTE, |
| 880 |
+ AV_PKT_DATA_NEW_EXTRADATA, |
|
| 881 |
+ AV_PKT_DATA_PARAM_CHANGE, |
|
| 880 | 882 |
}; |
| 881 | 883 |
|
| 882 | 884 |
typedef struct AVPacket {
|
| ... | ... |
@@ -946,6 +952,27 @@ typedef struct AVPacket {
|
| 946 | 946 |
#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted |
| 947 | 947 |
|
| 948 | 948 |
/** |
| 949 |
+ * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: |
|
| 950 |
+ * u32le param_flags |
|
| 951 |
+ * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) |
|
| 952 |
+ * s32le channel_count |
|
| 953 |
+ * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) |
|
| 954 |
+ * u64le channel_layout |
|
| 955 |
+ * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) |
|
| 956 |
+ * s32le sample_rate |
|
| 957 |
+ * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) |
|
| 958 |
+ * s32le width |
|
| 959 |
+ * s32le height |
|
| 960 |
+ */ |
|
| 961 |
+ |
|
| 962 |
+enum AVSideDataParamChangeFlags {
|
|
| 963 |
+ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, |
|
| 964 |
+ AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, |
|
| 965 |
+ AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, |
|
| 966 |
+ AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, |
|
| 967 |
+}; |
|
| 968 |
+ |
|
| 969 |
+/** |
|
| 949 | 970 |
* Audio Video Frame. |
| 950 | 971 |
* New fields can be added to the end of AVFRAME with minor version |
| 951 | 972 |
* bumps. Similarly fields that are marked as to be only accessed by |
| ... | ... |
@@ -4195,13 +4195,13 @@ int main(void){
|
| 4195 | 4195 |
|
| 4196 | 4196 |
s= show_bits(&gb, 24); |
| 4197 | 4197 |
|
| 4198 |
- START_TIMER |
|
| 4198 |
+ {START_TIMER
|
|
| 4199 | 4199 |
j= get_ue_golomb(&gb); |
| 4200 | 4200 |
if(j != i){
|
| 4201 | 4201 |
printf("mismatch! at %d (%d should be %d) bits:%6X\n", i, j, i, s);
|
| 4202 | 4202 |
// return -1; |
| 4203 | 4203 |
} |
| 4204 |
- STOP_TIMER("get_ue_golomb");
|
|
| 4204 |
+ STOP_TIMER("get_ue_golomb");}
|
|
| 4205 | 4205 |
} |
| 4206 | 4206 |
|
| 4207 | 4207 |
|
| ... | ... |
@@ -4220,13 +4220,13 @@ int main(void){
|
| 4220 | 4220 |
|
| 4221 | 4221 |
s= show_bits(&gb, 24); |
| 4222 | 4222 |
|
| 4223 |
- START_TIMER |
|
| 4223 |
+ {START_TIMER
|
|
| 4224 | 4224 |
j= get_se_golomb(&gb); |
| 4225 | 4225 |
if(j != i - COUNT/2){
|
| 4226 | 4226 |
printf("mismatch! at %d (%d should be %d) bits:%6X\n", i, j, i, s);
|
| 4227 | 4227 |
// return -1; |
| 4228 | 4228 |
} |
| 4229 |
- STOP_TIMER("get_se_golomb");
|
|
| 4229 |
+ STOP_TIMER("get_se_golomb");}
|
|
| 4230 | 4230 |
} |
| 4231 | 4231 |
|
| 4232 | 4232 |
printf("Testing RBSP\n");
|
| ... | ... |
@@ -1657,7 +1657,7 @@ decode_cabac_residual_internal(H264Context *h, DCTELEM *block, |
| 1657 | 1657 |
index[coeff_count++] = last;\ |
| 1658 | 1658 |
} |
| 1659 | 1659 |
const uint8_t *sig_off = significant_coeff_flag_offset_8x8[MB_FIELD]; |
| 1660 |
-#if ARCH_X86 && HAVE_7REGS && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) |
|
| 1660 |
+#if ARCH_X86 && HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) |
|
| 1661 | 1661 |
coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, |
| 1662 | 1662 |
last_coeff_ctx_base, sig_off); |
| 1663 | 1663 |
} else {
|
| ... | ... |
@@ -35,8 +35,9 @@ static void lpc_apply_welch_window_c(const int32_t *data, int len, |
| 35 | 35 |
double w; |
| 36 | 36 |
double c; |
| 37 | 37 |
|
| 38 |
- assert(!(len&1)); //the optimization in r11881 does not support odd len |
|
| 39 |
- //if someone wants odd len extend the change in r11881 |
|
| 38 |
+ /* The optimization in commit fa4ed8c does not support odd len. |
|
| 39 |
+ * If someone wants odd len extend that change. */ |
|
| 40 |
+ assert(!(len & 1)); |
|
| 40 | 41 |
|
| 41 | 42 |
n2 = (len >> 1); |
| 42 | 43 |
c = 2.0 / (len - 1.0); |
| ... | ... |
@@ -226,7 +226,7 @@ AVCodec ff_nellymoser_decoder = {
|
| 226 | 226 |
.init = decode_init, |
| 227 | 227 |
.close = decode_end, |
| 228 | 228 |
.decode = decode_tag, |
| 229 |
- .capabilities = CODEC_CAP_DR1, |
|
| 229 |
+ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_PARAM_CHANGE, |
|
| 230 | 230 |
.long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"),
|
| 231 | 231 |
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT,
|
| 232 | 232 |
AV_SAMPLE_FMT_S16, |
| ... | ... |
@@ -41,6 +41,7 @@ |
| 41 | 41 |
#include "thread.h" |
| 42 | 42 |
#include "audioconvert.h" |
| 43 | 43 |
#include "internal.h" |
| 44 |
+#include "bytestream.h" |
|
| 44 | 45 |
#include <stdlib.h> |
| 45 | 46 |
#include <stdarg.h> |
| 46 | 47 |
#include <limits.h> |
| ... | ... |
@@ -1028,6 +1029,47 @@ int attribute_align_arg avcodec_decode_audio3(AVCodecContext *avctx, int16_t *sa |
| 1028 | 1028 |
} |
| 1029 | 1029 |
#endif |
| 1030 | 1030 |
|
| 1031 |
+static void apply_param_change(AVCodecContext *avctx, AVPacket *avpkt) |
|
| 1032 |
+{
|
|
| 1033 |
+ int size = 0; |
|
| 1034 |
+ const uint8_t *data; |
|
| 1035 |
+ uint32_t flags; |
|
| 1036 |
+ |
|
| 1037 |
+ if (!(avctx->codec->capabilities & CODEC_CAP_PARAM_CHANGE)) |
|
| 1038 |
+ return; |
|
| 1039 |
+ |
|
| 1040 |
+ data = av_packet_get_side_data(avpkt, AV_PKT_DATA_PARAM_CHANGE, &size); |
|
| 1041 |
+ if (!data || size < 4) |
|
| 1042 |
+ return; |
|
| 1043 |
+ flags = bytestream_get_le32(&data); |
|
| 1044 |
+ size -= 4; |
|
| 1045 |
+ if (size < 4) /* Required for any of the changes */ |
|
| 1046 |
+ return; |
|
| 1047 |
+ if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) {
|
|
| 1048 |
+ avctx->channels = bytestream_get_le32(&data); |
|
| 1049 |
+ size -= 4; |
|
| 1050 |
+ } |
|
| 1051 |
+ if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) {
|
|
| 1052 |
+ if (size < 8) |
|
| 1053 |
+ return; |
|
| 1054 |
+ avctx->channel_layout = bytestream_get_le64(&data); |
|
| 1055 |
+ size -= 8; |
|
| 1056 |
+ } |
|
| 1057 |
+ if (size < 4) |
|
| 1058 |
+ return; |
|
| 1059 |
+ if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) {
|
|
| 1060 |
+ avctx->sample_rate = bytestream_get_le32(&data); |
|
| 1061 |
+ size -= 4; |
|
| 1062 |
+ } |
|
| 1063 |
+ if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) {
|
|
| 1064 |
+ if (size < 8) |
|
| 1065 |
+ return; |
|
| 1066 |
+ avctx->width = bytestream_get_le32(&data); |
|
| 1067 |
+ avctx->height = bytestream_get_le32(&data); |
|
| 1068 |
+ size -= 8; |
|
| 1069 |
+ } |
|
| 1070 |
+} |
|
| 1071 |
+ |
|
| 1031 | 1072 |
int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, |
| 1032 | 1073 |
AVFrame *frame, |
| 1033 | 1074 |
int *got_frame_ptr, |
| ... | ... |
@@ -1044,6 +1086,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, |
| 1044 | 1044 |
|
| 1045 | 1045 |
if ((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size) {
|
| 1046 | 1046 |
av_packet_split_side_data(avpkt); |
| 1047 |
+ apply_param_change(avctx, avpkt); |
|
| 1048 |
+ |
|
| 1047 | 1049 |
avctx->pkt = avpkt; |
| 1048 | 1050 |
ret = avctx->codec->decode(avctx, frame, got_frame_ptr, avpkt); |
| 1049 | 1051 |
if (ret >= 0 && *got_frame_ptr) {
|
| ... | ... |
@@ -21,8 +21,8 @@ |
| 21 | 21 |
#define AVCODEC_VERSION_H |
| 22 | 22 |
|
| 23 | 23 |
#define LIBAVCODEC_VERSION_MAJOR 53 |
| 24 |
-#define LIBAVCODEC_VERSION_MINOR 46 |
|
| 25 |
-#define LIBAVCODEC_VERSION_MICRO 1 |
|
| 24 |
+#define LIBAVCODEC_VERSION_MINOR 47 |
|
| 25 |
+#define LIBAVCODEC_VERSION_MICRO 0 |
|
| 26 | 26 |
|
| 27 | 27 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 28 | 28 |
LIBAVCODEC_VERSION_MINOR, \ |
| ... | ... |
@@ -139,7 +139,7 @@ static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) |
| 139 | 139 |
win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); |
| 140 | 140 |
if (!win32_cond->semaphore) |
| 141 | 141 |
return; |
| 142 |
- win32_cond->waiters_done = CreateEvent(NULL, FALSE, FALSE, NULL); |
|
| 142 |
+ win32_cond->waiters_done = CreateEvent(NULL, TRUE, FALSE, NULL); |
|
| 143 | 143 |
if (!win32_cond->waiters_done) |
| 144 | 144 |
return; |
| 145 | 145 |
|
| ... | ... |
@@ -204,11 +204,10 @@ static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) |
| 204 | 204 |
|
| 205 | 205 |
/* non native condition variables */ |
| 206 | 206 |
pthread_mutex_lock(&win32_cond->mtx_broadcast); |
| 207 |
- pthread_mutex_unlock(&win32_cond->mtx_broadcast); |
|
| 208 |
- |
|
| 209 | 207 |
pthread_mutex_lock(&win32_cond->mtx_waiter_count); |
| 210 | 208 |
win32_cond->waiter_count++; |
| 211 | 209 |
pthread_mutex_unlock(&win32_cond->mtx_waiter_count); |
| 210 |
+ pthread_mutex_unlock(&win32_cond->mtx_broadcast); |
|
| 212 | 211 |
|
| 213 | 212 |
// unlock the external mutex |
| 214 | 213 |
pthread_mutex_unlock(mutex); |
| ... | ... |
@@ -216,7 +215,7 @@ static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) |
| 216 | 216 |
|
| 217 | 217 |
pthread_mutex_lock(&win32_cond->mtx_waiter_count); |
| 218 | 218 |
win32_cond->waiter_count--; |
| 219 |
- last_waiter = !win32_cond->waiter_count && win32_cond->is_broadcast; |
|
| 219 |
+ last_waiter = !win32_cond->waiter_count || !win32_cond->is_broadcast; |
|
| 220 | 220 |
pthread_mutex_unlock(&win32_cond->mtx_waiter_count); |
| 221 | 221 |
|
| 222 | 222 |
if (last_waiter) |
| ... | ... |
@@ -235,13 +234,20 @@ static void pthread_cond_signal(pthread_cond_t *cond) |
| 235 | 235 |
return; |
| 236 | 236 |
} |
| 237 | 237 |
|
| 238 |
+ pthread_mutex_lock(&win32_cond->mtx_broadcast); |
|
| 239 |
+ |
|
| 238 | 240 |
/* non-native condition variables */ |
| 239 | 241 |
pthread_mutex_lock(&win32_cond->mtx_waiter_count); |
| 240 | 242 |
have_waiter = win32_cond->waiter_count; |
| 241 | 243 |
pthread_mutex_unlock(&win32_cond->mtx_waiter_count); |
| 242 | 244 |
|
| 243 |
- if (have_waiter) |
|
| 245 |
+ if (have_waiter) {
|
|
| 244 | 246 |
ReleaseSemaphore(win32_cond->semaphore, 1, NULL); |
| 247 |
+ WaitForSingleObject(win32_cond->waiters_done, INFINITE); |
|
| 248 |
+ ResetEvent(win32_cond->waiters_done); |
|
| 249 |
+ } |
|
| 250 |
+ |
|
| 251 |
+ pthread_mutex_unlock(&win32_cond->mtx_broadcast); |
|
| 245 | 252 |
} |
| 246 | 253 |
|
| 247 | 254 |
static void w32thread_init(void) |
| ... | ... |
@@ -1338,6 +1338,7 @@ static int decode_packet(AVCodecContext *avctx, |
| 1338 | 1338 |
*data_size = 0; |
| 1339 | 1339 |
|
| 1340 | 1340 |
if (s->packet_done || s->packet_loss) {
|
| 1341 |
+ int seekable_frame_in_packet, spliced_packet; |
|
| 1341 | 1342 |
s->packet_done = 0; |
| 1342 | 1343 |
|
| 1343 | 1344 |
/** sanity check for the buffer length */ |
| ... | ... |
@@ -1351,8 +1352,8 @@ static int decode_packet(AVCodecContext *avctx, |
| 1351 | 1351 |
/** parse packet header */ |
| 1352 | 1352 |
init_get_bits(gb, buf, s->buf_bit_size); |
| 1353 | 1353 |
packet_sequence_number = get_bits(gb, 4); |
| 1354 |
- int seekable_frame_in_packet = get_bits1(gb); |
|
| 1355 |
- int spliced_packet = get_bits1(gb); |
|
| 1354 |
+ seekable_frame_in_packet = get_bits1(gb); |
|
| 1355 |
+ spliced_packet = get_bits1(gb); |
|
| 1356 | 1356 |
|
| 1357 | 1357 |
/** get number of bits that need to be added to the previous frame */ |
| 1358 | 1358 |
num_bits_prev_frame = get_bits(gb, s->log2_frame_size); |
| ... | ... |
@@ -36,7 +36,7 @@ |
| 36 | 36 |
|
| 37 | 37 |
//FIXME use some macros to avoid duplicating get_cabac (cannot be done yet |
| 38 | 38 |
//as that would make optimization work hard) |
| 39 |
-#if HAVE_6REGS && !defined(BROKEN_RELOCATIONS) |
|
| 39 |
+#if HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) |
|
| 40 | 40 |
static int decode_significance_x86(CABACContext *c, int max_coeff, |
| 41 | 41 |
uint8_t *significant_coeff_ctx_base, |
| 42 | 42 |
int *index, x86_reg last_off){
|
| ... | ... |
@@ -144,6 +144,6 @@ static int decode_significance_8x8_x86(CABACContext *c, |
| 144 | 144 |
); |
| 145 | 145 |
return coeff_count; |
| 146 | 146 |
} |
| 147 |
-#endif /* HAVE_6REGS && !defined(BROKEN_RELOCATIONS) */ |
|
| 147 |
+#endif /* HAVE_EBX_AVAILABLE && !defined(BROKEN_RELOCATIONS) */ |
|
| 148 | 148 |
|
| 149 | 149 |
#endif /* AVCODEC_X86_H264_I386_H */ |
| ... | ... |
@@ -987,7 +987,7 @@ static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pk |
| 987 | 987 |
asf_st->packet_pos= asf->packet_pos; |
| 988 | 988 |
if (asf_st->pkt.data && asf_st->palette_changed) {
|
| 989 | 989 |
uint8_t *pal; |
| 990 |
- pal = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, |
|
| 990 |
+ pal = av_packet_new_side_data(&asf_st->pkt, AV_PKT_DATA_PALETTE, |
|
| 991 | 991 |
AVPALETTE_SIZE); |
| 992 | 992 |
if (!pal) {
|
| 993 | 993 |
av_log(s, AV_LOG_ERROR, "Cannot append palette to packet\n"); |
| ... | ... |
@@ -102,7 +102,7 @@ static int flac_read_header(AVFormatContext *s, |
| 102 | 102 |
uint8_t isrc[13]; |
| 103 | 103 |
uint64_t start; |
| 104 | 104 |
const uint8_t *offset; |
| 105 |
- int i, j, chapters, track, ti; |
|
| 105 |
+ int i, chapters, track, ti; |
|
| 106 | 106 |
if (metadata_size < 431) |
| 107 | 107 |
return AVERROR_INVALIDDATA; |
| 108 | 108 |
offset = buffer + 395; |
| ... | ... |
@@ -119,8 +119,7 @@ static int flac_read_header(AVFormatContext *s, |
| 119 | 119 |
offset += 14; |
| 120 | 120 |
ti = bytestream_get_byte(&offset); |
| 121 | 121 |
if (ti <= 0) return AVERROR_INVALIDDATA; |
| 122 |
- for (j = 0; j < ti; j++) |
|
| 123 |
- offset += 12; |
|
| 122 |
+ offset += ti * 12; |
|
| 124 | 123 |
avpriv_new_chapter(s, track, st->time_base, start, AV_NOPTS_VALUE, isrc); |
| 125 | 124 |
} |
| 126 | 125 |
} else {
|
| ... | ... |
@@ -37,6 +37,10 @@ |
| 37 | 37 |
|
| 38 | 38 |
typedef struct {
|
| 39 | 39 |
int wrong_dts; ///< wrong dts due to negative cts |
| 40 |
+ uint8_t *new_extradata[FLV_STREAM_TYPE_NB]; |
|
| 41 |
+ int new_extradata_size[FLV_STREAM_TYPE_NB]; |
|
| 42 |
+ int last_sample_rate; |
|
| 43 |
+ int last_channels; |
|
| 40 | 44 |
} FLVContext; |
| 41 | 45 |
|
| 42 | 46 |
static int flv_probe(AVProbeData *p) |
| ... | ... |
@@ -50,8 +54,7 @@ static int flv_probe(AVProbeData *p) |
| 50 | 50 |
return 0; |
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 |
-static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, int flv_codecid) {
|
|
| 54 |
- AVCodecContext *acodec = astream->codec; |
|
| 53 |
+static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream, AVCodecContext *acodec, int flv_codecid) {
|
|
| 55 | 54 |
switch(flv_codecid) {
|
| 56 | 55 |
//no distinction between S16 and S8 PCM codec flags |
| 57 | 56 |
case FLV_CODECID_PCM: |
| ... | ... |
@@ -411,6 +414,15 @@ static int flv_read_header(AVFormatContext *s, |
| 411 | 411 |
return 0; |
| 412 | 412 |
} |
| 413 | 413 |
|
| 414 |
+static int flv_read_close(AVFormatContext *s) |
|
| 415 |
+{
|
|
| 416 |
+ int i; |
|
| 417 |
+ FLVContext *flv = s->priv_data; |
|
| 418 |
+ for(i=0; i<FLV_STREAM_TYPE_NB; i++) |
|
| 419 |
+ av_freep(&flv->new_extradata[i]); |
|
| 420 |
+ return 0; |
|
| 421 |
+} |
|
| 422 |
+ |
|
| 414 | 423 |
static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size) |
| 415 | 424 |
{
|
| 416 | 425 |
av_free(st->codec->extradata); |
| ... | ... |
@@ -422,6 +434,18 @@ static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size) |
| 422 | 422 |
return 0; |
| 423 | 423 |
} |
| 424 | 424 |
|
| 425 |
+static int flv_queue_extradata(FLVContext *flv, AVIOContext *pb, int stream, |
|
| 426 |
+ int size) |
|
| 427 |
+{
|
|
| 428 |
+ av_free(flv->new_extradata[stream]); |
|
| 429 |
+ flv->new_extradata[stream] = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); |
|
| 430 |
+ if (!flv->new_extradata[stream]) |
|
| 431 |
+ return AVERROR(ENOMEM); |
|
| 432 |
+ flv->new_extradata_size[stream] = size; |
|
| 433 |
+ avio_read(pb, flv->new_extradata[stream], size); |
|
| 434 |
+ return 0; |
|
| 435 |
+} |
|
| 436 |
+ |
|
| 425 | 437 |
static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 426 | 438 |
{
|
| 427 | 439 |
FLVContext *flv = s->priv_data; |
| ... | ... |
@@ -429,6 +453,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 429 | 429 |
int stream_type=-1; |
| 430 | 430 |
int64_t next, pos; |
| 431 | 431 |
int64_t dts, pts = AV_NOPTS_VALUE; |
| 432 |
+ int sample_rate, channels; |
|
| 432 | 433 |
AVStream *st = NULL; |
| 433 | 434 |
|
| 434 | 435 |
for(;;avio_skip(s->pb, 4)){ /* pkt size is repeated at end. skip it */
|
| ... | ... |
@@ -518,13 +543,24 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 518 | 518 |
} |
| 519 | 519 |
|
| 520 | 520 |
if(stream_type == FLV_STREAM_TYPE_AUDIO){
|
| 521 |
+ int bits_per_coded_sample; |
|
| 522 |
+ channels = (flags & FLV_AUDIO_CHANNEL_MASK) == FLV_STEREO ? 2 : 1; |
|
| 523 |
+ sample_rate = (44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >> FLV_AUDIO_SAMPLERATE_OFFSET) >> 3); |
|
| 524 |
+ bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8; |
|
| 521 | 525 |
if(!st->codec->channels || !st->codec->sample_rate || !st->codec->bits_per_coded_sample) {
|
| 522 |
- st->codec->channels = (flags & FLV_AUDIO_CHANNEL_MASK) == FLV_STEREO ? 2 : 1; |
|
| 523 |
- st->codec->sample_rate = (44100 << ((flags & FLV_AUDIO_SAMPLERATE_MASK) >> FLV_AUDIO_SAMPLERATE_OFFSET) >> 3); |
|
| 524 |
- st->codec->bits_per_coded_sample = (flags & FLV_AUDIO_SAMPLESIZE_MASK) ? 16 : 8; |
|
| 526 |
+ st->codec->channels = channels; |
|
| 527 |
+ st->codec->sample_rate = sample_rate; |
|
| 528 |
+ st->codec->bits_per_coded_sample = bits_per_coded_sample; |
|
| 525 | 529 |
} |
| 526 | 530 |
if(!st->codec->codec_id){
|
| 527 |
- flv_set_audio_codec(s, st, flags & FLV_AUDIO_CODECID_MASK); |
|
| 531 |
+ flv_set_audio_codec(s, st, st->codec, flags & FLV_AUDIO_CODECID_MASK); |
|
| 532 |
+ flv->last_sample_rate = st->codec->sample_rate; |
|
| 533 |
+ flv->last_channels = st->codec->channels; |
|
| 534 |
+ } else {
|
|
| 535 |
+ AVCodecContext ctx; |
|
| 536 |
+ ctx.sample_rate = sample_rate; |
|
| 537 |
+ flv_set_audio_codec(s, st, &ctx, flags & FLV_AUDIO_CODECID_MASK); |
|
| 538 |
+ sample_rate = ctx.sample_rate; |
|
| 528 | 539 |
} |
| 529 | 540 |
} else if(stream_type == FLV_STREAM_TYPE_VIDEO) {
|
| 530 | 541 |
size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK); |
| ... | ... |
@@ -545,8 +581,13 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 545 | 545 |
if (flv->wrong_dts) |
| 546 | 546 |
dts = AV_NOPTS_VALUE; |
| 547 | 547 |
} |
| 548 |
- |
|
| 549 |
- if (type == 0 && !st->codec->extradata) {
|
|
| 548 |
+ if (type == 0 && (!st->codec->extradata || st->codec->codec_id != CODEC_ID_H264)) {
|
|
| 549 |
+ if (st->codec->extradata) {
|
|
| 550 |
+ if ((ret = flv_queue_extradata(flv, s->pb, stream_type, size)) < 0) |
|
| 551 |
+ return ret; |
|
| 552 |
+ ret = AVERROR(EAGAIN); |
|
| 553 |
+ goto leave; |
|
| 554 |
+ } |
|
| 550 | 555 |
if ((ret = flv_get_extradata(s, st, size)) < 0) |
| 551 | 556 |
return ret; |
| 552 | 557 |
if (st->codec->codec_id == CODEC_ID_AAC) {
|
| ... | ... |
@@ -583,8 +624,22 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt) |
| 583 | 583 |
pkt->dts = dts; |
| 584 | 584 |
pkt->pts = pts == AV_NOPTS_VALUE ? dts : pts; |
| 585 | 585 |
pkt->stream_index = st->index; |
| 586 |
- if(st->codec->codec_id == CODEC_ID_NELLYMOSER) |
|
| 587 |
- av_packet_new_side_data(pkt, 'F', 1)[0]= flags; |
|
| 586 |
+ if (flv->new_extradata[stream_type]) {
|
|
| 587 |
+ uint8_t *side = av_packet_new_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA, |
|
| 588 |
+ flv->new_extradata_size[stream_type]); |
|
| 589 |
+ if (side) {
|
|
| 590 |
+ memcpy(side, flv->new_extradata[stream_type], |
|
| 591 |
+ flv->new_extradata_size[stream_type]); |
|
| 592 |
+ av_freep(&flv->new_extradata[stream_type]); |
|
| 593 |
+ flv->new_extradata_size[stream_type] = 0; |
|
| 594 |
+ } |
|
| 595 |
+ } |
|
| 596 |
+ if (stream_type == FLV_STREAM_TYPE_AUDIO && (sample_rate != flv->last_sample_rate || |
|
| 597 |
+ channels != flv->last_channels)) {
|
|
| 598 |
+ flv->last_sample_rate = sample_rate; |
|
| 599 |
+ flv->last_channels = channels; |
|
| 600 |
+ ff_add_param_change(pkt, channels, 0, sample_rate, 0, 0); |
|
| 601 |
+ } |
|
| 588 | 602 |
|
| 589 | 603 |
if ( stream_type == FLV_STREAM_TYPE_AUDIO || |
| 590 | 604 |
((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY) || |
| ... | ... |
@@ -640,6 +695,7 @@ AVInputFormat ff_flv_demuxer = {
|
| 640 | 640 |
#if 0 |
| 641 | 641 |
.read_seek2 = flv_read_seek2, |
| 642 | 642 |
#endif |
| 643 |
+ .read_close = flv_read_close, |
|
| 643 | 644 |
.extensions = "flv", |
| 644 | 645 |
.value = CODEC_ID_FLV1, |
| 645 | 646 |
}; |
| ... | ... |
@@ -45,6 +45,7 @@ |
| 45 | 45 |
|
| 46 | 46 |
typedef struct RoqDemuxContext {
|
| 47 | 47 |
|
| 48 |
+ int frame_rate; |
|
| 48 | 49 |
int width; |
| 49 | 50 |
int height; |
| 50 | 51 |
int audio_channels; |
| ... | ... |
@@ -71,29 +72,21 @@ static int roq_read_header(AVFormatContext *s, |
| 71 | 71 |
{
|
| 72 | 72 |
RoqDemuxContext *roq = s->priv_data; |
| 73 | 73 |
AVIOContext *pb = s->pb; |
| 74 |
- int framerate; |
|
| 75 |
- AVStream *st; |
|
| 76 | 74 |
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE]; |
| 77 | 75 |
|
| 78 | 76 |
/* get the main header */ |
| 79 | 77 |
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != |
| 80 | 78 |
RoQ_CHUNK_PREAMBLE_SIZE) |
| 81 | 79 |
return AVERROR(EIO); |
| 82 |
- framerate = AV_RL16(&preamble[6]); |
|
| 80 |
+ roq->frame_rate = AV_RL16(&preamble[6]); |
|
| 83 | 81 |
|
| 84 | 82 |
/* init private context parameters */ |
| 85 | 83 |
roq->width = roq->height = roq->audio_channels = roq->video_pts = |
| 86 | 84 |
roq->audio_frame_count = 0; |
| 87 | 85 |
roq->audio_stream_index = -1; |
| 86 |
+ roq->video_stream_index = -1; |
|
| 88 | 87 |
|
| 89 |
- st = avformat_new_stream(s, NULL); |
|
| 90 |
- if (!st) |
|
| 91 |
- return AVERROR(ENOMEM); |
|
| 92 |
- avpriv_set_pts_info(st, 63, 1, framerate); |
|
| 93 |
- roq->video_stream_index = st->index; |
|
| 94 |
- st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
|
| 95 |
- st->codec->codec_id = CODEC_ID_ROQ; |
|
| 96 |
- st->codec->codec_tag = 0; /* no fourcc */ |
|
| 88 |
+ s->ctx_flags |= AVFMTCTX_NOHEADER; |
|
| 97 | 89 |
|
| 98 | 90 |
return 0; |
| 99 | 91 |
} |
| ... | ... |
@@ -131,8 +124,16 @@ static int roq_read_packet(AVFormatContext *s, |
| 131 | 131 |
switch (chunk_type) {
|
| 132 | 132 |
|
| 133 | 133 |
case RoQ_INFO: |
| 134 |
- if (!roq->width || !roq->height) {
|
|
| 135 |
- AVStream *st = s->streams[roq->video_stream_index]; |
|
| 134 |
+ if (roq->video_stream_index == -1) {
|
|
| 135 |
+ AVStream *st = avformat_new_stream(s, NULL); |
|
| 136 |
+ if (!st) |
|
| 137 |
+ return AVERROR(ENOMEM); |
|
| 138 |
+ avpriv_set_pts_info(st, 63, 1, roq->frame_rate); |
|
| 139 |
+ roq->video_stream_index = st->index; |
|
| 140 |
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO; |
|
| 141 |
+ st->codec->codec_id = CODEC_ID_ROQ; |
|
| 142 |
+ st->codec->codec_tag = 0; /* no fourcc */ |
|
| 143 |
+ |
|
| 136 | 144 |
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE) |
| 137 | 145 |
return AVERROR(EIO); |
| 138 | 146 |
st->codec->width = roq->width = AV_RL16(preamble); |
| ... | ... |
@@ -298,4 +298,12 @@ int64_t ff_gen_search(AVFormatContext *s, int stream_index, |
| 298 | 298 |
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, |
| 299 | 299 |
unsigned int pts_num, unsigned int pts_den); |
| 300 | 300 |
|
| 301 |
+/** |
|
| 302 |
+ * Add side data to a packet for changing parameters to the given values. |
|
| 303 |
+ * Parameters set to 0 aren't included in the change. |
|
| 304 |
+ */ |
|
| 305 |
+int ff_add_param_change(AVPacket *pkt, int32_t channels, |
|
| 306 |
+ uint64_t channel_layout, int32_t sample_rate, |
|
| 307 |
+ int32_t width, int32_t height); |
|
| 308 |
+ |
|
| 301 | 309 |
#endif /* AVFORMAT_INTERNAL_H */ |
| ... | ... |
@@ -124,13 +124,16 @@ int ff_network_inited_globally; |
| 124 | 124 |
|
| 125 | 125 |
int ff_network_init(void) |
| 126 | 126 |
{
|
| 127 |
+#if HAVE_WINSOCK2_H |
|
| 128 |
+ WSADATA wsaData; |
|
| 129 |
+#endif |
|
| 130 |
+ |
|
| 127 | 131 |
if (!ff_network_inited_globally) |
| 128 | 132 |
av_log(NULL, AV_LOG_WARNING, "Using network protocols without global " |
| 129 | 133 |
"network initialization. Please use " |
| 130 | 134 |
"avformat_network_init(), this will " |
| 131 | 135 |
"become mandatory later.\n"); |
| 132 | 136 |
#if HAVE_WINSOCK2_H |
| 133 |
- WSADATA wsaData; |
|
| 134 | 137 |
if (WSAStartup(MAKEWORD(1,1), &wsaData)) |
| 135 | 138 |
return 0; |
| 136 | 139 |
#endif |
| ... | ... |
@@ -26,6 +26,7 @@ |
| 26 | 26 |
#include "internal.h" |
| 27 | 27 |
#include "libavcodec/internal.h" |
| 28 | 28 |
#include "libavcodec/raw.h" |
| 29 |
+#include "libavcodec/bytestream.h" |
|
| 29 | 30 |
#include "libavutil/opt.h" |
| 30 | 31 |
#include "libavutil/dict.h" |
| 31 | 32 |
#include "libavutil/pixdesc.h" |
| ... | ... |
@@ -4290,3 +4291,45 @@ int avformat_network_deinit(void) |
| 4290 | 4290 |
#endif |
| 4291 | 4291 |
return 0; |
| 4292 | 4292 |
} |
| 4293 |
+ |
|
| 4294 |
+int ff_add_param_change(AVPacket *pkt, int32_t channels, |
|
| 4295 |
+ uint64_t channel_layout, int32_t sample_rate, |
|
| 4296 |
+ int32_t width, int32_t height) |
|
| 4297 |
+{
|
|
| 4298 |
+ uint32_t flags = 0; |
|
| 4299 |
+ int size = 4; |
|
| 4300 |
+ uint8_t *data; |
|
| 4301 |
+ if (!pkt) |
|
| 4302 |
+ return AVERROR(EINVAL); |
|
| 4303 |
+ if (channels) {
|
|
| 4304 |
+ size += 4; |
|
| 4305 |
+ flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT; |
|
| 4306 |
+ } |
|
| 4307 |
+ if (channel_layout) {
|
|
| 4308 |
+ size += 8; |
|
| 4309 |
+ flags |= AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT; |
|
| 4310 |
+ } |
|
| 4311 |
+ if (sample_rate) {
|
|
| 4312 |
+ size += 4; |
|
| 4313 |
+ flags |= AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE; |
|
| 4314 |
+ } |
|
| 4315 |
+ if (width || height) {
|
|
| 4316 |
+ size += 8; |
|
| 4317 |
+ flags |= AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS; |
|
| 4318 |
+ } |
|
| 4319 |
+ data = av_packet_new_side_data(pkt, AV_PKT_DATA_PARAM_CHANGE, size); |
|
| 4320 |
+ if (!data) |
|
| 4321 |
+ return AVERROR(ENOMEM); |
|
| 4322 |
+ bytestream_put_le32(&data, flags); |
|
| 4323 |
+ if (channels) |
|
| 4324 |
+ bytestream_put_le32(&data, channels); |
|
| 4325 |
+ if (channel_layout) |
|
| 4326 |
+ bytestream_put_le64(&data, channel_layout); |
|
| 4327 |
+ if (sample_rate) |
|
| 4328 |
+ bytestream_put_le32(&data, sample_rate); |
|
| 4329 |
+ if (width || height) {
|
|
| 4330 |
+ bytestream_put_le32(&data, width); |
|
| 4331 |
+ bytestream_put_le32(&data, height); |
|
| 4332 |
+ } |
|
| 4333 |
+ return 0; |
|
| 4334 |
+} |
| ... | ... |
@@ -33,7 +33,7 @@ typedef union {
|
| 33 | 33 |
|
| 34 | 34 |
typedef struct AVAES {
|
| 35 | 35 |
// Note: round_key[16] is accessed in the init code, but this only |
| 36 |
- // overwrites state, which does not matter (see also r7471). |
|
| 36 |
+ // overwrites state, which does not matter (see also commit ba554c0). |
|
| 37 | 37 |
av_aes_block round_key[15]; |
| 38 | 38 |
av_aes_block state[2]; |
| 39 | 39 |
int rounds; |
| ... | ... |
@@ -530,6 +530,39 @@ static inline void doVertDefFilter_altivec(uint8_t src[], int stride, PPContext |
| 530 | 530 |
} |
| 531 | 531 |
|
| 532 | 532 |
static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 533 |
+ const vector signed int vsint32_8 = vec_splat_s32(8); |
|
| 534 |
+ const vector unsigned int vuint32_4 = vec_splat_u32(4); |
|
| 535 |
+ const vector signed char neg1 = vec_splat_s8(-1); |
|
| 536 |
+ |
|
| 537 |
+ const vector unsigned char permA1 = (vector unsigned char) |
|
| 538 |
+ {0x00, 0x01, 0x02, 0x10, 0x11, 0x12, 0x1F, 0x1F,
|
|
| 539 |
+ 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; |
|
| 540 |
+ const vector unsigned char permA2 = (vector unsigned char) |
|
| 541 |
+ {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x10, 0x11,
|
|
| 542 |
+ 0x12, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; |
|
| 543 |
+ const vector unsigned char permA1inc = (vector unsigned char) |
|
| 544 |
+ {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
|
|
| 545 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 546 |
+ const vector unsigned char permA2inc = (vector unsigned char) |
|
| 547 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
|
| 548 |
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 549 |
+ const vector unsigned char magic = (vector unsigned char) |
|
| 550 |
+ {0x01, 0x02, 0x01, 0x02, 0x04, 0x02, 0x01, 0x02,
|
|
| 551 |
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 552 |
+ const vector unsigned char extractPerm = (vector unsigned char) |
|
| 553 |
+ {0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01,
|
|
| 554 |
+ 0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01}; |
|
| 555 |
+ const vector unsigned char extractPermInc = (vector unsigned char) |
|
| 556 |
+ {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
|
| 557 |
+ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01}; |
|
| 558 |
+ const vector unsigned char identity = vec_lvsl(0,(unsigned char *)0); |
|
| 559 |
+ const vector unsigned char tenRight = (vector unsigned char) |
|
| 560 |
+ {0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
| 561 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 562 |
+ const vector unsigned char eightLeft = (vector unsigned char) |
|
| 563 |
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
| 564 |
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08}; |
|
| 565 |
+ |
|
| 533 | 566 |
/* |
| 534 | 567 |
this code makes no assumption on src or stride. |
| 535 | 568 |
One could remove the recomputation of the perm |
| ... | ... |
@@ -539,11 +572,9 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 539 | 539 |
src & stride :-( |
| 540 | 540 |
*/ |
| 541 | 541 |
uint8_t *srcCopy = src; |
| 542 |
- DECLARE_ALIGNED(16, uint8_t, dt)[16]; |
|
| 542 |
+ DECLARE_ALIGNED(16, uint8_t, dt)[16] = { deringThreshold };
|
|
| 543 | 543 |
const vector signed int zero = vec_splat_s32(0); |
| 544 |
- vector unsigned char v_dt; |
|
| 545 |
- dt[0] = deringThreshold; |
|
| 546 |
- v_dt = vec_splat(vec_ld(0, dt), 0); |
|
| 544 |
+ vector unsigned char v_dt = vec_splat(vec_ld(0, dt), 0); |
|
| 547 | 545 |
|
| 548 | 546 |
#define LOAD_LINE(i) \ |
| 549 | 547 |
const vector unsigned char perm##i = \ |
| ... | ... |
@@ -565,6 +596,11 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 565 | 565 |
#undef LOAD_LINE |
| 566 | 566 |
|
| 567 | 567 |
vector unsigned char v_avg; |
| 568 |
+ DECLARE_ALIGNED(16, signed int, S)[8]; |
|
| 569 |
+ DECLARE_ALIGNED(16, int, tQP2)[4] = { c->QP/2 + 1 };
|
|
| 570 |
+ vector signed int vQP2 = vec_ld(0, tQP2); |
|
| 571 |
+ vQP2 = vec_splat(vQP2, 0); |
|
| 572 |
+ |
|
| 568 | 573 |
{
|
| 569 | 574 |
const vector unsigned char trunc_perm = (vector unsigned char) |
| 570 | 575 |
{0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
|
| ... | ... |
@@ -575,21 +611,22 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 575 | 575 |
const vector unsigned char trunc_src78 = vec_perm(src7, src8, trunc_perm); |
| 576 | 576 |
|
| 577 | 577 |
#define EXTRACT(op) do { \
|
| 578 |
- const vector unsigned char s##op##_1 = vec_##op(trunc_src12, trunc_src34); \ |
|
| 579 |
- const vector unsigned char s##op##_2 = vec_##op(trunc_src56, trunc_src78); \ |
|
| 580 |
- const vector unsigned char s##op##_6 = vec_##op(s##op##_1, s##op##_2); \ |
|
| 581 |
- const vector unsigned char s##op##_8h = vec_mergeh(s##op##_6, s##op##_6); \ |
|
| 582 |
- const vector unsigned char s##op##_8l = vec_mergel(s##op##_6, s##op##_6); \ |
|
| 583 |
- const vector unsigned char s##op##_9 = vec_##op(s##op##_8h, s##op##_8l); \ |
|
| 584 |
- const vector unsigned char s##op##_9h = vec_mergeh(s##op##_9, s##op##_9); \ |
|
| 585 |
- const vector unsigned char s##op##_9l = vec_mergel(s##op##_9, s##op##_9); \ |
|
| 586 |
- const vector unsigned char s##op##_10 = vec_##op(s##op##_9h, s##op##_9l); \ |
|
| 587 |
- const vector unsigned char s##op##_10h = vec_mergeh(s##op##_10, s##op##_10); \ |
|
| 588 |
- const vector unsigned char s##op##_10l = vec_mergel(s##op##_10, s##op##_10); \ |
|
| 589 |
- const vector unsigned char s##op##_11 = vec_##op(s##op##_10h, s##op##_10l); \ |
|
| 590 |
- const vector unsigned char s##op##_11h = vec_mergeh(s##op##_11, s##op##_11); \ |
|
| 591 |
- const vector unsigned char s##op##_11l = vec_mergel(s##op##_11, s##op##_11); \ |
|
| 592 |
- v_##op = vec_##op(s##op##_11h, s##op##_11l); } while (0) |
|
| 578 |
+ const vector unsigned char s_1 = vec_##op(trunc_src12, trunc_src34); \ |
|
| 579 |
+ const vector unsigned char s_2 = vec_##op(trunc_src56, trunc_src78); \ |
|
| 580 |
+ const vector unsigned char s_6 = vec_##op(s_1, s_2); \ |
|
| 581 |
+ const vector unsigned char s_8h = vec_mergeh(s_6, s_6); \ |
|
| 582 |
+ const vector unsigned char s_8l = vec_mergel(s_6, s_6); \ |
|
| 583 |
+ const vector unsigned char s_9 = vec_##op(s_8h, s_8l); \ |
|
| 584 |
+ const vector unsigned char s_9h = vec_mergeh(s_9, s_9); \ |
|
| 585 |
+ const vector unsigned char s_9l = vec_mergel(s_9, s_9); \ |
|
| 586 |
+ const vector unsigned char s_10 = vec_##op(s_9h, s_9l); \ |
|
| 587 |
+ const vector unsigned char s_10h = vec_mergeh(s_10, s_10); \ |
|
| 588 |
+ const vector unsigned char s_10l = vec_mergel(s_10, s_10); \ |
|
| 589 |
+ const vector unsigned char s_11 = vec_##op(s_10h, s_10l); \ |
|
| 590 |
+ const vector unsigned char s_11h = vec_mergeh(s_11, s_11); \ |
|
| 591 |
+ const vector unsigned char s_11l = vec_mergel(s_11, s_11); \ |
|
| 592 |
+ v_##op = vec_##op(s_11h, s_11l); \ |
|
| 593 |
+} while (0) |
|
| 593 | 594 |
|
| 594 | 595 |
vector unsigned char v_min; |
| 595 | 596 |
vector unsigned char v_max; |
| ... | ... |
@@ -603,7 +640,6 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 603 | 603 |
v_avg = vec_avg(v_min, v_max); |
| 604 | 604 |
} |
| 605 | 605 |
|
| 606 |
- DECLARE_ALIGNED(16, signed int, S)[8]; |
|
| 607 | 606 |
{
|
| 608 | 607 |
const vector unsigned short mask1 = (vector unsigned short) |
| 609 | 608 |
{0x0001, 0x0002, 0x0004, 0x0008,
|
| ... | ... |
@@ -615,22 +651,27 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 615 | 615 |
const vector unsigned int vuint32_16 = vec_sl(vec_splat_u32(1), vec_splat_u32(4)); |
| 616 | 616 |
const vector unsigned int vuint32_1 = vec_splat_u32(1); |
| 617 | 617 |
|
| 618 |
+ vector signed int sumA2; |
|
| 619 |
+ vector signed int sumB2; |
|
| 620 |
+ vector signed int sum0, sum1, sum2, sum3, sum4; |
|
| 621 |
+ vector signed int sum5, sum6, sum7, sum8, sum9; |
|
| 622 |
+ |
|
| 618 | 623 |
#define COMPARE(i) \ |
| 619 |
- vector signed int sum##i; \ |
|
| 620 | 624 |
do { \
|
| 621 |
- const vector unsigned char cmp##i = \ |
|
| 625 |
+ const vector unsigned char cmp = \ |
|
| 622 | 626 |
(vector unsigned char)vec_cmpgt(src##i, v_avg); \ |
| 623 |
- const vector unsigned short cmpHi##i = \ |
|
| 624 |
- (vector unsigned short)vec_mergeh(cmp##i, cmp##i); \ |
|
| 625 |
- const vector unsigned short cmpLi##i = \ |
|
| 626 |
- (vector unsigned short)vec_mergel(cmp##i, cmp##i); \ |
|
| 627 |
- const vector signed short cmpHf##i = \ |
|
| 628 |
- (vector signed short)vec_and(cmpHi##i, mask1); \ |
|
| 629 |
- const vector signed short cmpLf##i = \ |
|
| 630 |
- (vector signed short)vec_and(cmpLi##i, mask2); \ |
|
| 631 |
- const vector signed int sump##i = vec_sum4s(cmpHf##i, zero); \ |
|
| 632 |
- const vector signed int sumq##i = vec_sum4s(cmpLf##i, sump##i); \ |
|
| 633 |
- sum##i = vec_sums(sumq##i, zero); } while (0) |
|
| 627 |
+ const vector unsigned short cmpHi = \ |
|
| 628 |
+ (vector unsigned short)vec_mergeh(cmp, cmp); \ |
|
| 629 |
+ const vector unsigned short cmpLi = \ |
|
| 630 |
+ (vector unsigned short)vec_mergel(cmp, cmp); \ |
|
| 631 |
+ const vector signed short cmpHf = \ |
|
| 632 |
+ (vector signed short)vec_and(cmpHi, mask1); \ |
|
| 633 |
+ const vector signed short cmpLf = \ |
|
| 634 |
+ (vector signed short)vec_and(cmpLi, mask2); \ |
|
| 635 |
+ const vector signed int sump = vec_sum4s(cmpHf, zero); \ |
|
| 636 |
+ const vector signed int sumq = vec_sum4s(cmpLf, sump); \ |
|
| 637 |
+ sum##i = vec_sums(sumq, zero); \ |
|
| 638 |
+ } while (0) |
|
| 634 | 639 |
|
| 635 | 640 |
COMPARE(0); |
| 636 | 641 |
COMPARE(1); |
| ... | ... |
@@ -644,8 +685,6 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 644 | 644 |
COMPARE(9); |
| 645 | 645 |
#undef COMPARE |
| 646 | 646 |
|
| 647 |
- vector signed int sumA2; |
|
| 648 |
- vector signed int sumB2; |
|
| 649 | 647 |
{
|
| 650 | 648 |
const vector signed int sump02 = vec_mergel(sum0, sum2); |
| 651 | 649 |
const vector signed int sump13 = vec_mergel(sum1, sum3); |
| ... | ... |
@@ -699,86 +738,43 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 699 | 699 |
/* I'm not sure the following is actually faster |
| 700 | 700 |
than straight, unvectorized C code :-( */ |
| 701 | 701 |
|
| 702 |
- DECLARE_ALIGNED(16, int, tQP2)[4]; |
|
| 703 |
- tQP2[0]= c->QP/2 + 1; |
|
| 704 |
- vector signed int vQP2 = vec_ld(0, tQP2); |
|
| 705 |
- vQP2 = vec_splat(vQP2, 0); |
|
| 706 |
- const vector signed int vsint32_8 = vec_splat_s32(8); |
|
| 707 |
- const vector unsigned int vuint32_4 = vec_splat_u32(4); |
|
| 708 |
- |
|
| 709 |
- const vector unsigned char permA1 = (vector unsigned char) |
|
| 710 |
- {0x00, 0x01, 0x02, 0x10, 0x11, 0x12, 0x1F, 0x1F,
|
|
| 711 |
- 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; |
|
| 712 |
- const vector unsigned char permA2 = (vector unsigned char) |
|
| 713 |
- {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x10, 0x11,
|
|
| 714 |
- 0x12, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F}; |
|
| 715 |
- const vector unsigned char permA1inc = (vector unsigned char) |
|
| 716 |
- {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00,
|
|
| 717 |
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 718 |
- const vector unsigned char permA2inc = (vector unsigned char) |
|
| 719 |
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
|
| 720 |
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 721 |
- const vector unsigned char magic = (vector unsigned char) |
|
| 722 |
- {0x01, 0x02, 0x01, 0x02, 0x04, 0x02, 0x01, 0x02,
|
|
| 723 |
- 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 724 |
- const vector unsigned char extractPerm = (vector unsigned char) |
|
| 725 |
- {0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01,
|
|
| 726 |
- 0x10, 0x10, 0x10, 0x01, 0x10, 0x10, 0x10, 0x01}; |
|
| 727 |
- const vector unsigned char extractPermInc = (vector unsigned char) |
|
| 728 |
- {0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
|
| 729 |
- 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01}; |
|
| 730 |
- const vector unsigned char identity = vec_lvsl(0,(unsigned char *)0); |
|
| 731 |
- const vector unsigned char tenRight = (vector unsigned char) |
|
| 732 |
- {0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
| 733 |
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
|
| 734 |
- const vector unsigned char eightLeft = (vector unsigned char) |
|
| 735 |
- {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
| 736 |
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08}; |
|
| 737 |
- |
|
| 738 |
- |
|
| 739 |
-#define F_INIT(i) \ |
|
| 740 |
- vector unsigned char tenRightM##i = tenRight; \ |
|
| 741 |
- vector unsigned char permA1M##i = permA1; \ |
|
| 742 |
- vector unsigned char permA2M##i = permA2; \ |
|
| 743 |
- vector unsigned char extractPermM##i = extractPerm |
|
| 702 |
+#define F_INIT() \ |
|
| 703 |
+ vector unsigned char tenRightM = tenRight; \ |
|
| 704 |
+ vector unsigned char permA1M = permA1; \ |
|
| 705 |
+ vector unsigned char permA2M = permA2; \ |
|
| 706 |
+ vector unsigned char extractPermM = extractPerm |
|
| 744 | 707 |
|
| 745 | 708 |
#define F2(i, j, k, l) \ |
| 746 | 709 |
if (S[i] & (1 << (l+1))) { \
|
| 747 |
- const vector unsigned char a_##j##_A##l = \ |
|
| 748 |
- vec_perm(src##i, src##j, permA1M##i); \ |
|
| 749 |
- const vector unsigned char a_##j##_B##l = \ |
|
| 750 |
- vec_perm(a_##j##_A##l, src##k, permA2M##i); \ |
|
| 751 |
- const vector signed int a_##j##_sump##l = \ |
|
| 752 |
- (vector signed int)vec_msum(a_##j##_B##l, magic, \ |
|
| 753 |
- (vector unsigned int)zero); \ |
|
| 754 |
- vector signed int F_##j##_##l = \ |
|
| 755 |
- vec_sr(vec_sums(a_##j##_sump##l, vsint32_8), vuint32_4); \ |
|
| 756 |
- F_##j##_##l = vec_splat(F_##j##_##l, 3); \ |
|
| 757 |
- const vector signed int p_##j##_##l = \ |
|
| 758 |
- (vector signed int)vec_perm(src##j, \ |
|
| 759 |
- (vector unsigned char)zero, \ |
|
| 760 |
- extractPermM##i); \ |
|
| 761 |
- const vector signed int sum_##j##_##l = vec_add( p_##j##_##l, vQP2);\ |
|
| 762 |
- const vector signed int diff_##j##_##l = vec_sub( p_##j##_##l, vQP2);\ |
|
| 763 |
- vector signed int newpm_##j##_##l; \ |
|
| 764 |
- if (vec_all_lt(sum_##j##_##l, F_##j##_##l)) \ |
|
| 765 |
- newpm_##j##_##l = sum_##j##_##l; \ |
|
| 766 |
- else if (vec_all_gt(diff_##j##_##l, F_##j##_##l)) \ |
|
| 767 |
- newpm_##j##_##l = diff_##j##_##l; \ |
|
| 768 |
- else newpm_##j##_##l = F_##j##_##l; \ |
|
| 769 |
- const vector unsigned char newpm2_##j##_##l = \ |
|
| 770 |
- vec_splat((vector unsigned char)newpm_##j##_##l, 15); \ |
|
| 771 |
- const vector unsigned char mask##j##l = vec_add(identity, \ |
|
| 772 |
- tenRightM##i); \ |
|
| 773 |
- src##j = vec_perm(src##j, newpm2_##j##_##l, mask##j##l); \ |
|
| 710 |
+ const vector unsigned char a_A = vec_perm(src##i, src##j, permA1M); \ |
|
| 711 |
+ const vector unsigned char a_B = vec_perm(a_A, src##k, permA2M); \ |
|
| 712 |
+ const vector signed int a_sump = \ |
|
| 713 |
+ (vector signed int)vec_msum(a_B, magic, (vector unsigned int)zero);\ |
|
| 714 |
+ vector signed int F = vec_sr(vec_sums(a_sump, vsint32_8), vuint32_4); \ |
|
| 715 |
+ const vector signed int p = \ |
|
| 716 |
+ (vector signed int)vec_perm(src##j, (vector unsigned char)zero, \ |
|
| 717 |
+ extractPermM); \ |
|
| 718 |
+ const vector signed int sum = vec_add(p, vQP2); \ |
|
| 719 |
+ const vector signed int diff = vec_sub(p, vQP2); \ |
|
| 720 |
+ vector signed int newpm; \ |
|
| 721 |
+ vector unsigned char newpm2, mask; \ |
|
| 722 |
+ F = vec_splat(F, 3); \ |
|
| 723 |
+ if (vec_all_lt(sum, F)) \ |
|
| 724 |
+ newpm = sum; \ |
|
| 725 |
+ else if (vec_all_gt(diff, F)) \ |
|
| 726 |
+ newpm = diff; \ |
|
| 727 |
+ else newpm = F; \ |
|
| 728 |
+ newpm2 = vec_splat((vector unsigned char)newpm, 15); \ |
|
| 729 |
+ mask = vec_add(identity, tenRightM); \ |
|
| 730 |
+ src##j = vec_perm(src##j, newpm2, mask); \ |
|
| 774 | 731 |
} \ |
| 775 |
- permA1M##i = vec_add(permA1M##i, permA1inc); \ |
|
| 776 |
- permA2M##i = vec_add(permA2M##i, permA2inc); \ |
|
| 777 |
- tenRightM##i = vec_sro(tenRightM##i, eightLeft); \ |
|
| 778 |
- extractPermM##i = vec_add(extractPermM##i, extractPermInc) |
|
| 732 |
+ permA1M = vec_add(permA1M, permA1inc); \ |
|
| 733 |
+ permA2M = vec_add(permA2M, permA2inc); \ |
|
| 734 |
+ tenRightM = vec_sro(tenRightM, eightLeft); \ |
|
| 735 |
+ extractPermM = vec_add(extractPermM, extractPermInc) |
|
| 779 | 736 |
|
| 780 |
-#define ITER(i, j, k) \ |
|
| 781 |
- F_INIT(i); \ |
|
| 737 |
+#define ITER(i, j, k) do { \
|
|
| 738 |
+ F_INIT(); \ |
|
| 782 | 739 |
F2(i, j, k, 0); \ |
| 783 | 740 |
F2(i, j, k, 1); \ |
| 784 | 741 |
F2(i, j, k, 2); \ |
| ... | ... |
@@ -786,7 +782,8 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 786 | 786 |
F2(i, j, k, 4); \ |
| 787 | 787 |
F2(i, j, k, 5); \ |
| 788 | 788 |
F2(i, j, k, 6); \ |
| 789 |
- F2(i, j, k, 7) |
|
| 789 |
+ F2(i, j, k, 7); \ |
|
| 790 |
+} while (0) |
|
| 790 | 791 |
|
| 791 | 792 |
ITER(0, 1, 2); |
| 792 | 793 |
ITER(1, 2, 3); |
| ... | ... |
@@ -797,19 +794,18 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 797 | 797 |
ITER(6, 7, 8); |
| 798 | 798 |
ITER(7, 8, 9); |
| 799 | 799 |
|
| 800 |
- const vector signed char neg1 = vec_splat_s8(-1); |
|
| 801 |
- |
|
| 802 |
-#define STORE_LINE(i) \ |
|
| 803 |
- const vector unsigned char permST##i = \ |
|
| 800 |
+#define STORE_LINE(i) do { \
|
|
| 801 |
+ const vector unsigned char permST = \ |
|
| 804 | 802 |
vec_lvsr(i * stride, srcCopy); \ |
| 805 |
- const vector unsigned char maskST##i = \ |
|
| 803 |
+ const vector unsigned char maskST = \ |
|
| 806 | 804 |
vec_perm((vector unsigned char)zero, \ |
| 807 |
- (vector unsigned char)neg1, permST##i);\ |
|
| 808 |
- src##i = vec_perm(src##i ,src##i, permST##i); \ |
|
| 809 |
- sA##i= vec_sel(sA##i, src##i, maskST##i); \ |
|
| 810 |
- sB##i= vec_sel(src##i, sB##i, maskST##i); \ |
|
| 805 |
+ (vector unsigned char)neg1, permST); \ |
|
| 806 |
+ src##i = vec_perm(src##i ,src##i, permST); \ |
|
| 807 |
+ sA##i= vec_sel(sA##i, src##i, maskST); \ |
|
| 808 |
+ sB##i= vec_sel(src##i, sB##i, maskST); \ |
|
| 811 | 809 |
vec_st(sA##i, i * stride, srcCopy); \ |
| 812 |
- vec_st(sB##i, i * stride + 16, srcCopy) |
|
| 810 |
+ vec_st(sB##i, i * stride + 16, srcCopy); \ |
|
| 811 |
+} while (0) |
|
| 813 | 812 |
|
| 814 | 813 |
STORE_LINE(1); |
| 815 | 814 |
STORE_LINE(2); |
| ... | ... |
@@ -832,16 +828,16 @@ static inline void dering_altivec(uint8_t src[], int stride, PPContext *c) {
|
| 832 | 832 |
static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
| 833 | 833 |
uint8_t *tempBlurred, uint32_t *tempBlurredPast, int *maxNoise) |
| 834 | 834 |
{
|
| 835 |
+ const vector signed char neg1 = vec_splat_s8(-1); |
|
| 836 |
+ const vector unsigned char permHH = (const vector unsigned char){0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
| 837 |
+ 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}; |
|
| 838 |
+ |
|
| 835 | 839 |
const vector signed int zero = vec_splat_s32(0); |
| 836 | 840 |
const vector signed short vsint16_1 = vec_splat_s16(1); |
| 837 | 841 |
vector signed int v_dp = zero; |
| 838 | 842 |
vector signed int v_sysdp = zero; |
| 839 | 843 |
int d, sysd, i; |
| 840 | 844 |
|
| 841 |
- tempBlurredPast[127]= maxNoise[0]; |
|
| 842 |
- tempBlurredPast[128]= maxNoise[1]; |
|
| 843 |
- tempBlurredPast[129]= maxNoise[2]; |
|
| 844 |
- |
|
| 845 | 845 |
#define LOAD_LINE(src, i) \ |
| 846 | 846 |
register int j##src##i = i * stride; \ |
| 847 | 847 |
vector unsigned char perm##src##i = vec_lvsl(j##src##i, src); \ |
| ... | ... |
@@ -872,11 +868,12 @@ static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
| 872 | 872 |
LOAD_LINE(tempBlurred, 7); |
| 873 | 873 |
#undef LOAD_LINE |
| 874 | 874 |
|
| 875 |
-#define ACCUMULATE_DIFFS(i) \ |
|
| 876 |
- vector signed short v_d##i = vec_sub(v_tempBlurredAss##i, \ |
|
| 877 |
- v_srcAss##i); \ |
|
| 878 |
- v_dp = vec_msums(v_d##i, v_d##i, v_dp); \ |
|
| 879 |
- v_sysdp = vec_msums(v_d##i, vsint16_1, v_sysdp) |
|
| 875 |
+#define ACCUMULATE_DIFFS(i) do { \
|
|
| 876 |
+ vector signed short v_d = vec_sub(v_tempBlurredAss##i, \ |
|
| 877 |
+ v_srcAss##i); \ |
|
| 878 |
+ v_dp = vec_msums(v_d, v_d, v_dp); \ |
|
| 879 |
+ v_sysdp = vec_msums(v_d, vsint16_1, v_sysdp); \ |
|
| 880 |
+ } while (0) |
|
| 880 | 881 |
|
| 881 | 882 |
ACCUMULATE_DIFFS(0); |
| 882 | 883 |
ACCUMULATE_DIFFS(1); |
| ... | ... |
@@ -888,6 +885,10 @@ static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
| 888 | 888 |
ACCUMULATE_DIFFS(7); |
| 889 | 889 |
#undef ACCUMULATE_DIFFS |
| 890 | 890 |
|
| 891 |
+ tempBlurredPast[127]= maxNoise[0]; |
|
| 892 |
+ tempBlurredPast[128]= maxNoise[1]; |
|
| 893 |
+ tempBlurredPast[129]= maxNoise[2]; |
|
| 894 |
+ |
|
| 891 | 895 |
v_dp = vec_sums(v_dp, zero); |
| 892 | 896 |
v_sysdp = vec_sums(v_sysdp, zero); |
| 893 | 897 |
|
| ... | ... |
@@ -938,13 +939,12 @@ static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
| 938 | 938 |
const vector signed short vsint16_4 = vec_splat_s16(4); |
| 939 | 939 |
const vector unsigned short vuint16_3 = vec_splat_u16(3); |
| 940 | 940 |
|
| 941 |
-#define OP(i) \ |
|
| 942 |
- const vector signed short v_temp##i = \ |
|
| 943 |
- vec_mladd(v_tempBlurredAss##i, \ |
|
| 944 |
- vsint16_7, v_srcAss##i); \ |
|
| 945 |
- const vector signed short v_temp2##i = \ |
|
| 946 |
- vec_add(v_temp##i, vsint16_4); \ |
|
| 947 |
- v_tempBlurredAss##i = vec_sr(v_temp2##i, vuint16_3) |
|
| 941 |
+#define OP(i) do { \
|
|
| 942 |
+ const vector signed short v_temp = \ |
|
| 943 |
+ vec_mladd(v_tempBlurredAss##i, vsint16_7, v_srcAss##i); \ |
|
| 944 |
+ const vector signed short v_temp2 = vec_add(v_temp, vsint16_4); \ |
|
| 945 |
+ v_tempBlurredAss##i = vec_sr(v_temp2, vuint16_3); \ |
|
| 946 |
+ } while (0) |
|
| 948 | 947 |
|
| 949 | 948 |
OP(0); |
| 950 | 949 |
OP(1); |
| ... | ... |
@@ -959,13 +959,13 @@ static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
| 959 | 959 |
const vector signed short vsint16_3 = vec_splat_s16(3); |
| 960 | 960 |
const vector signed short vsint16_2 = vec_splat_s16(2); |
| 961 | 961 |
|
| 962 |
-#define OP(i) \ |
|
| 963 |
- const vector signed short v_temp##i = \ |
|
| 964 |
- vec_mladd(v_tempBlurredAss##i, \ |
|
| 965 |
- vsint16_3, v_srcAss##i); \ |
|
| 966 |
- const vector signed short v_temp2##i = \ |
|
| 967 |
- vec_add(v_temp##i, vsint16_2); \ |
|
| 968 |
- v_tempBlurredAss##i = vec_sr(v_temp2##i, (vector unsigned short)vsint16_2) |
|
| 962 |
+#define OP(i) do { \
|
|
| 963 |
+ const vector signed short v_temp = \ |
|
| 964 |
+ vec_mladd(v_tempBlurredAss##i, vsint16_3, v_srcAss##i); \ |
|
| 965 |
+ const vector signed short v_temp2 = vec_add(v_temp, vsint16_2); \ |
|
| 966 |
+ v_tempBlurredAss##i = \ |
|
| 967 |
+ vec_sr(v_temp2, (vector unsigned short)vsint16_2); \ |
|
| 968 |
+ } while (0) |
|
| 969 | 969 |
|
| 970 | 970 |
OP(0); |
| 971 | 971 |
OP(1); |
| ... | ... |
@@ -979,27 +979,19 @@ static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride, |
| 979 | 979 |
} |
| 980 | 980 |
} |
| 981 | 981 |
|
| 982 |
- const vector signed char neg1 = vec_splat_s8(-1); |
|
| 983 |
- const vector unsigned char permHH = (const vector unsigned char){0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
|
| 984 |
- 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F}; |
|
| 985 |
- |
|
| 986 |
-#define PACK_AND_STORE(src, i) \ |
|
| 987 |
- const vector unsigned char perms##src##i = \ |
|
| 988 |
- vec_lvsr(i * stride, src); \ |
|
| 989 |
- const vector unsigned char vf##src##i = \ |
|
| 990 |
- vec_packsu(v_tempBlurredAss##i, (vector signed short)zero); \ |
|
| 991 |
- const vector unsigned char vg##src##i = \ |
|
| 992 |
- vec_perm(vf##src##i, v_##src##A##i, permHH); \ |
|
| 993 |
- const vector unsigned char mask##src##i = \ |
|
| 994 |
- vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms##src##i); \ |
|
| 995 |
- const vector unsigned char vg2##src##i = \ |
|
| 996 |
- vec_perm(vg##src##i, vg##src##i, perms##src##i); \ |
|
| 997 |
- const vector unsigned char svA##src##i = \ |
|
| 998 |
- vec_sel(v_##src##A1##i, vg2##src##i, mask##src##i); \ |
|
| 999 |
- const vector unsigned char svB##src##i = \ |
|
| 1000 |
- vec_sel(vg2##src##i, v_##src##A2##i, mask##src##i); \ |
|
| 1001 |
- vec_st(svA##src##i, i * stride, src); \ |
|
| 1002 |
- vec_st(svB##src##i, i * stride + 16, src) |
|
| 982 |
+#define PACK_AND_STORE(src, i) do { \
|
|
| 983 |
+ const vector unsigned char perms = vec_lvsr(i * stride, src); \ |
|
| 984 |
+ const vector unsigned char vf = \ |
|
| 985 |
+ vec_packsu(v_tempBlurredAss##1, (vector signed short)zero); \ |
|
| 986 |
+ const vector unsigned char vg = vec_perm(vf, v_##src##A##i, permHH); \ |
|
| 987 |
+ const vector unsigned char mask = \ |
|
| 988 |
+ vec_perm((vector unsigned char)zero, (vector unsigned char)neg1, perms); \ |
|
| 989 |
+ const vector unsigned char vg2 = vec_perm(vg, vg, perms); \ |
|
| 990 |
+ const vector unsigned char svA = vec_sel(v_##src##A1##i, vg2, mask); \ |
|
| 991 |
+ const vector unsigned char svB = vec_sel(vg2, v_##src##A2##i, mask); \ |
|
| 992 |
+ vec_st(svA, i * stride, src); \ |
|
| 993 |
+ vec_st(svB, i * stride + 16, src); \ |
|
| 994 |
+} while (0) |
|
| 1003 | 995 |
|
| 1004 | 996 |
PACK_AND_STORE(src, 0); |
| 1005 | 997 |
PACK_AND_STORE(src, 1); |
| ... | ... |
@@ -1127,6 +1119,7 @@ static inline void transpose_16x8_char_toPackedAlign_altivec(unsigned char* dst, |
| 1127 | 1127 |
|
| 1128 | 1128 |
static inline void transpose_8x16_char_fromPackedAlign_altivec(unsigned char* dst, unsigned char* src, int stride) {
|
| 1129 | 1129 |
const vector unsigned char zero = vec_splat_u8(0); |
| 1130 |
+ const vector signed char neg1 = vec_splat_s8(-1); |
|
| 1130 | 1131 |
|
| 1131 | 1132 |
#define LOAD_DOUBLE_LINE(i, j) \ |
| 1132 | 1133 |
vector unsigned char src##i = vec_ld(i * 16, src); \ |
| ... | ... |
@@ -1187,26 +1180,28 @@ static inline void transpose_8x16_char_fromPackedAlign_altivec(unsigned char* ds |
| 1187 | 1187 |
temp7 = vec_mergel(tempD, tempL); |
| 1188 | 1188 |
|
| 1189 | 1189 |
|
| 1190 |
- const vector signed char neg1 = vec_splat_s8(-1); |
|
| 1191 |
-#define STORE_DOUBLE_LINE(i, j) \ |
|
| 1192 |
- vector unsigned char dstA##i = vec_ld(i * stride, dst); \ |
|
| 1193 |
- vector unsigned char dstB##i = vec_ld(i * stride + 16, dst); \ |
|
| 1194 |
- vector unsigned char dstA##j = vec_ld(j * stride, dst); \ |
|
| 1195 |
- vector unsigned char dstB##j = vec_ld(j * stride+ 16, dst); \ |
|
| 1196 |
- vector unsigned char align##i = vec_lvsr(i * stride, dst); \ |
|
| 1197 |
- vector unsigned char align##j = vec_lvsr(j * stride, dst); \ |
|
| 1198 |
- vector unsigned char mask##i = vec_perm(zero, (vector unsigned char)neg1, align##i); \ |
|
| 1199 |
- vector unsigned char mask##j = vec_perm(zero, (vector unsigned char)neg1, align##j); \ |
|
| 1200 |
- vector unsigned char dstR##i = vec_perm(temp##i, temp##i, align##i);\ |
|
| 1201 |
- vector unsigned char dstR##j = vec_perm(temp##j, temp##j, align##j);\ |
|
| 1202 |
- vector unsigned char dstAF##i = vec_sel(dstA##i, dstR##i, mask##i); \ |
|
| 1203 |
- vector unsigned char dstBF##i = vec_sel(dstR##i, dstB##i, mask##i); \ |
|
| 1204 |
- vector unsigned char dstAF##j = vec_sel(dstA##j, dstR##j, mask##j); \ |
|
| 1205 |
- vector unsigned char dstBF##j = vec_sel(dstR##j, dstB##j, mask##j); \ |
|
| 1206 |
- vec_st(dstAF##i, i * stride, dst); \ |
|
| 1207 |
- vec_st(dstBF##i, i * stride + 16, dst); \ |
|
| 1208 |
- vec_st(dstAF##j, j * stride, dst); \ |
|
| 1209 |
- vec_st(dstBF##j, j * stride + 16, dst) |
|
| 1190 |
+#define STORE_DOUBLE_LINE(i, j) do { \
|
|
| 1191 |
+ vector unsigned char dstAi = vec_ld(i * stride, dst); \ |
|
| 1192 |
+ vector unsigned char dstBi = vec_ld(i * stride + 16, dst); \ |
|
| 1193 |
+ vector unsigned char dstAj = vec_ld(j * stride, dst); \ |
|
| 1194 |
+ vector unsigned char dstBj = vec_ld(j * stride+ 16, dst); \ |
|
| 1195 |
+ vector unsigned char aligni = vec_lvsr(i * stride, dst); \ |
|
| 1196 |
+ vector unsigned char alignj = vec_lvsr(j * stride, dst); \ |
|
| 1197 |
+ vector unsigned char maski = \ |
|
| 1198 |
+ vec_perm(zero, (vector unsigned char)neg1, aligni); \ |
|
| 1199 |
+ vector unsigned char maskj = \ |
|
| 1200 |
+ vec_perm(zero, (vector unsigned char)neg1, alignj); \ |
|
| 1201 |
+ vector unsigned char dstRi = vec_perm(temp##i, temp##i, aligni); \ |
|
| 1202 |
+ vector unsigned char dstRj = vec_perm(temp##j, temp##j, alignj); \ |
|
| 1203 |
+ vector unsigned char dstAFi = vec_sel(dstAi, dstRi, maski); \ |
|
| 1204 |
+ vector unsigned char dstBFi = vec_sel(dstRi, dstBi, maski); \ |
|
| 1205 |
+ vector unsigned char dstAFj = vec_sel(dstAj, dstRj, maskj); \ |
|
| 1206 |
+ vector unsigned char dstBFj = vec_sel(dstRj, dstBj, maskj); \ |
|
| 1207 |
+ vec_st(dstAFi, i * stride, dst); \ |
|
| 1208 |
+ vec_st(dstBFi, i * stride + 16, dst); \ |
|
| 1209 |
+ vec_st(dstAFj, j * stride, dst); \ |
|
| 1210 |
+ vec_st(dstBFj, j * stride + 16, dst); \ |
|
| 1211 |
+} while (0) |
|
| 1210 | 1212 |
|
| 1211 | 1213 |
STORE_DOUBLE_LINE(0,1); |
| 1212 | 1214 |
STORE_DOUBLE_LINE(2,3); |
| ... | ... |
@@ -3515,9 +3515,10 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[ |
| 3515 | 3515 |
else if(mode & H_DEBLOCK){
|
| 3516 | 3516 |
#if HAVE_ALTIVEC |
| 3517 | 3517 |
DECLARE_ALIGNED(16, unsigned char, tempBlock)[272]; |
| 3518 |
+ int t; |
|
| 3518 | 3519 |
transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride); |
| 3519 | 3520 |
|
| 3520 |
- const int t=vertClassify_altivec(tempBlock-48, 16, &c); |
|
| 3521 |
+ t = vertClassify_altivec(tempBlock-48, 16, &c); |
|
| 3521 | 3522 |
if(t==1) {
|
| 3522 | 3523 |
doVertLowPass_altivec(tempBlock-48, 16, &c); |
| 3523 | 3524 |
transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); |