Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
F
ffmpeg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ffmpeg
Commits
16c22122
Commit
16c22122
authored
Jul 26, 2013
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
h264: K&R formatting cosmetics
parent
96668944
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
28 deletions
+38
-28
h264.c
libavcodec/h264.c
+38
-28
No files found.
libavcodec/h264.c
View file @
16c22122
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
* @author Michael Niedermayer <michaelni@gmx.at>
* @author Michael Niedermayer <michaelni@gmx.at>
*/
*/
#include "libavutil/avassert.h"
#include "libavutil/imgutils.h"
#include "libavutil/imgutils.h"
#include "internal.h"
#include "internal.h"
#include "cabac.h"
#include "cabac.h"
...
@@ -43,7 +44,6 @@
...
@@ -43,7 +44,6 @@
#include "svq3.h"
#include "svq3.h"
#include "thread.h"
#include "thread.h"
#include "vdpau_internal.h"
#include "vdpau_internal.h"
#include "libavutil/avassert.h"
// #undef NDEBUG
// #undef NDEBUG
#include <assert.h>
#include <assert.h>
...
@@ -213,7 +213,6 @@ static int ref_picture(H264Context *h, Picture *dst, Picture *src)
...
@@ -213,7 +213,6 @@ static int ref_picture(H264Context *h, Picture *dst, Picture *src)
if
(
ret
<
0
)
if
(
ret
<
0
)
goto
fail
;
goto
fail
;
dst
->
qscale_table_buf
=
av_buffer_ref
(
src
->
qscale_table_buf
);
dst
->
qscale_table_buf
=
av_buffer_ref
(
src
->
qscale_table_buf
);
dst
->
mb_type_buf
=
av_buffer_ref
(
src
->
mb_type_buf
);
dst
->
mb_type_buf
=
av_buffer_ref
(
src
->
mb_type_buf
);
if
(
!
dst
->
qscale_table_buf
||
!
dst
->
mb_type_buf
)
if
(
!
dst
->
qscale_table_buf
||
!
dst
->
mb_type_buf
)
...
@@ -221,7 +220,7 @@ static int ref_picture(H264Context *h, Picture *dst, Picture *src)
...
@@ -221,7 +220,7 @@ static int ref_picture(H264Context *h, Picture *dst, Picture *src)
dst
->
qscale_table
=
src
->
qscale_table
;
dst
->
qscale_table
=
src
->
qscale_table
;
dst
->
mb_type
=
src
->
mb_type
;
dst
->
mb_type
=
src
->
mb_type
;
for
(
i
=
0
;
i
<
2
;
i
++
)
{
for
(
i
=
0
;
i
<
2
;
i
++
)
{
dst
->
motion_val_buf
[
i
]
=
av_buffer_ref
(
src
->
motion_val_buf
[
i
]);
dst
->
motion_val_buf
[
i
]
=
av_buffer_ref
(
src
->
motion_val_buf
[
i
]);
dst
->
ref_index_buf
[
i
]
=
av_buffer_ref
(
src
->
ref_index_buf
[
i
]);
dst
->
ref_index_buf
[
i
]
=
av_buffer_ref
(
src
->
ref_index_buf
[
i
]);
if
(
!
dst
->
motion_val_buf
[
i
]
||
!
dst
->
ref_index_buf
[
i
])
if
(
!
dst
->
motion_val_buf
[
i
]
||
!
dst
->
ref_index_buf
[
i
])
...
@@ -259,7 +258,6 @@ fail:
...
@@ -259,7 +258,6 @@ fail:
return
ret
;
return
ret
;
}
}
static
int
alloc_scratch_buffers
(
H264Context
*
h
,
int
linesize
)
static
int
alloc_scratch_buffers
(
H264Context
*
h
,
int
linesize
)
{
{
int
alloc_size
=
FFALIGN
(
FFABS
(
linesize
)
+
32
,
32
);
int
alloc_size
=
FFALIGN
(
FFABS
(
linesize
)
+
32
,
32
);
...
@@ -510,12 +508,14 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
...
@@ -510,12 +508,14 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
} \
} \
break; \
break; \
}
}
#if HAVE_FAST_UNALIGNED
#if HAVE_FAST_UNALIGNED
#define FIND_FIRST_ZERO \
#define FIND_FIRST_ZERO \
if (i > 0 && !src[i]) \
if (i > 0 && !src[i]) \
i--; \
i--; \
while (src[i]) \
while (src[i]) \
i++
i++
#if HAVE_FAST_64BIT
#if HAVE_FAST_64BIT
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
9
)
{
for
(
i
=
0
;
i
+
1
<
length
;
i
+=
9
)
{
if
(
!
((
~
AV_RN64A
(
src
+
i
)
&
if
(
!
((
~
AV_RN64A
(
src
+
i
)
&
...
@@ -583,8 +583,8 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
...
@@ -583,8 +583,8 @@ const uint8_t *ff_h264_decode_nal(H264Context *h, const uint8_t *src,
}
}
while
(
si
<
length
)
while
(
si
<
length
)
dst
[
di
++
]
=
src
[
si
++
];
dst
[
di
++
]
=
src
[
si
++
];
nsc:
nsc:
memset
(
dst
+
di
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
memset
(
dst
+
di
,
0
,
FF_INPUT_BUFFER_PADDING_SIZE
);
*
dst_length
=
di
;
*
dst_length
=
di
;
...
@@ -2338,7 +2338,8 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
...
@@ -2338,7 +2338,8 @@ static av_always_inline void hl_decode_mb_predict_luma(H264Context *h,
0
*
16
,
1
*
16
,
4
*
16
,
5
*
16
,
0
*
16
,
1
*
16
,
4
*
16
,
5
*
16
,
2
*
16
,
3
*
16
,
6
*
16
,
7
*
16
,
2
*
16
,
3
*
16
,
6
*
16
,
7
*
16
,
8
*
16
,
9
*
16
,
12
*
16
,
13
*
16
,
8
*
16
,
9
*
16
,
12
*
16
,
13
*
16
,
10
*
16
,
11
*
16
,
14
*
16
,
15
*
16
};
10
*
16
,
11
*
16
,
14
*
16
,
15
*
16
};
for
(
i
=
0
;
i
<
16
;
i
++
)
for
(
i
=
0
;
i
<
16
;
i
++
)
dctcoef_set
(
h
->
mb
+
(
p
*
256
<<
pixel_shift
),
dctcoef_set
(
h
->
mb
+
(
p
*
256
<<
pixel_shift
),
pixel_shift
,
dc_mapping
[
i
],
pixel_shift
,
dc_mapping
[
i
],
...
@@ -2438,7 +2439,8 @@ void ff_h264_hl_decode_mb(H264Context *h)
...
@@ -2438,7 +2439,8 @@ void ff_h264_hl_decode_mb(H264Context *h)
{
{
const
int
mb_xy
=
h
->
mb_xy
;
const
int
mb_xy
=
h
->
mb_xy
;
const
int
mb_type
=
h
->
cur_pic
.
mb_type
[
mb_xy
];
const
int
mb_type
=
h
->
cur_pic
.
mb_type
[
mb_xy
];
int
is_complex
=
CONFIG_SMALL
||
h
->
is_complex
||
IS_INTRA_PCM
(
mb_type
)
||
h
->
qscale
==
0
;
int
is_complex
=
CONFIG_SMALL
||
h
->
is_complex
||
IS_INTRA_PCM
(
mb_type
)
||
h
->
qscale
==
0
;
if
(
CHROMA444
(
h
))
{
if
(
CHROMA444
(
h
))
{
if
(
is_complex
||
h
->
pixel_shift
)
if
(
is_complex
||
h
->
pixel_shift
)
...
@@ -2654,9 +2656,11 @@ int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
...
@@ -2654,9 +2656,11 @@ int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
if
(
h
->
sps
.
poc_type
==
0
)
{
if
(
h
->
sps
.
poc_type
==
0
)
{
const
int
max_poc_lsb
=
1
<<
h
->
sps
.
log2_max_poc_lsb
;
const
int
max_poc_lsb
=
1
<<
h
->
sps
.
log2_max_poc_lsb
;
if
(
h
->
poc_lsb
<
h
->
prev_poc_lsb
&&
h
->
prev_poc_lsb
-
h
->
poc_lsb
>=
max_poc_lsb
/
2
)
if
(
h
->
poc_lsb
<
h
->
prev_poc_lsb
&&
h
->
prev_poc_lsb
-
h
->
poc_lsb
>=
max_poc_lsb
/
2
)
h
->
poc_msb
=
h
->
prev_poc_msb
+
max_poc_lsb
;
h
->
poc_msb
=
h
->
prev_poc_msb
+
max_poc_lsb
;
else
if
(
h
->
poc_lsb
>
h
->
prev_poc_lsb
&&
h
->
prev_poc_lsb
-
h
->
poc_lsb
<
-
max_poc_lsb
/
2
)
else
if
(
h
->
poc_lsb
>
h
->
prev_poc_lsb
&&
h
->
prev_poc_lsb
-
h
->
poc_lsb
<
-
max_poc_lsb
/
2
)
h
->
poc_msb
=
h
->
prev_poc_msb
-
max_poc_lsb
;
h
->
poc_msb
=
h
->
prev_poc_msb
-
max_poc_lsb
;
else
else
h
->
poc_msb
=
h
->
prev_poc_msb
;
h
->
poc_msb
=
h
->
prev_poc_msb
;
...
@@ -3250,7 +3254,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
...
@@ -3250,7 +3254,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
(
h
->
width
!=
h
->
avctx
->
coded_width
||
(
h
->
width
!=
h
->
avctx
->
coded_width
||
h
->
height
!=
h
->
avctx
->
coded_height
||
h
->
height
!=
h
->
avctx
->
coded_height
||
needs_reinit
))
{
needs_reinit
))
{
if
(
h
!=
h0
)
{
if
(
h
!=
h0
)
{
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"changing width/height on "
av_log
(
h
->
avctx
,
AV_LOG_ERROR
,
"changing width/height on "
"slice %d
\n
"
,
h0
->
current_slice
+
1
);
"slice %d
\n
"
,
h0
->
current_slice
+
1
);
...
@@ -3417,17 +3420,22 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
...
@@ -3417,17 +3420,22 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
if
(
ff_h264_execute_ref_pic_marking
(
h
,
h
->
mmco
,
h
->
mmco_index
)
<
0
&&
if
(
ff_h264_execute_ref_pic_marking
(
h
,
h
->
mmco
,
h
->
mmco_index
)
<
0
&&
(
h
->
avctx
->
err_recognition
&
AV_EF_EXPLODE
))
(
h
->
avctx
->
err_recognition
&
AV_EF_EXPLODE
))
return
AVERROR_INVALIDDATA
;
return
AVERROR_INVALIDDATA
;
/* Error concealment: if a ref is missing, copy the previous ref in its place.
/* Error concealment: If a ref is missing, copy the previous ref
* FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions
* in its place.
* about there being no actual duplicates.
* FIXME: Avoiding a memcpy would be nice, but ref handling makes
* FIXME: this doesn't copy padding for out-of-frame motion vectors. Given we're
* many assumptions about there being no actual duplicates.
* concealing a lost frame, this probably isn't noticeable by comparison, but it should
* FIXME: This does not copy padding for out-of-frame motion
* be fixed. */
* vectors. Given we are concealing a lost frame, this probably
* is not noticeable by comparison, but it should be fixed. */
if
(
h
->
short_ref_count
)
{
if
(
h
->
short_ref_count
)
{
if
(
prev
)
{
if
(
prev
)
{
av_image_copy
(
h
->
short_ref
[
0
]
->
f
.
data
,
h
->
short_ref
[
0
]
->
f
.
linesize
,
av_image_copy
(
h
->
short_ref
[
0
]
->
f
.
data
,
(
const
uint8_t
**
)
prev
->
f
.
data
,
prev
->
f
.
linesize
,
h
->
short_ref
[
0
]
->
f
.
linesize
,
h
->
avctx
->
pix_fmt
,
h
->
mb_width
*
16
,
h
->
mb_height
*
16
);
(
const
uint8_t
**
)
prev
->
f
.
data
,
prev
->
f
.
linesize
,
h
->
avctx
->
pix_fmt
,
h
->
mb_width
*
16
,
h
->
mb_height
*
16
);
h
->
short_ref
[
0
]
->
poc
=
prev
->
poc
+
2
;
h
->
short_ref
[
0
]
->
poc
=
prev
->
poc
+
2
;
}
}
h
->
short_ref
[
0
]
->
frame_num
=
h
->
prev_frame_num
;
h
->
short_ref
[
0
]
->
frame_num
=
h
->
prev_frame_num
;
...
@@ -3486,7 +3494,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
...
@@ -3486,7 +3494,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
return
-
1
;
return
-
1
;
}
}
h
->
resync_mb_x
=
h
->
mb_x
=
first_mb_in_slice
%
h
->
mb_width
;
h
->
resync_mb_x
=
h
->
mb_x
=
first_mb_in_slice
%
h
->
mb_width
;
h
->
resync_mb_y
=
h
->
mb_y
=
(
first_mb_in_slice
/
h
->
mb_width
)
<<
FIELD_OR_MBAFF_PICTURE
(
h
);
h
->
resync_mb_y
=
h
->
mb_y
=
(
first_mb_in_slice
/
h
->
mb_width
)
<<
FIELD_OR_MBAFF_PICTURE
(
h
);
if
(
h
->
picture_structure
==
PICT_BOTTOM_FIELD
)
if
(
h
->
picture_structure
==
PICT_BOTTOM_FIELD
)
h
->
resync_mb_y
=
h
->
mb_y
=
h
->
mb_y
+
1
;
h
->
resync_mb_y
=
h
->
mb_y
=
h
->
mb_y
+
1
;
assert
(
h
->
mb_y
<
h
->
mb_height
);
assert
(
h
->
mb_y
<
h
->
mb_height
);
...
@@ -3550,7 +3559,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
...
@@ -3550,7 +3559,6 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
h
->
ref_count
[
0
]
=
h
->
ref_count
[
1
]
=
0
;
h
->
ref_count
[
0
]
=
h
->
ref_count
[
1
]
=
0
;
}
}
max_refs
=
h
->
picture_structure
==
PICT_FRAME
?
16
:
32
;
max_refs
=
h
->
picture_structure
==
PICT_FRAME
?
16
:
32
;
if
(
h
->
ref_count
[
0
]
>
max_refs
||
h
->
ref_count
[
1
]
>
max_refs
)
{
if
(
h
->
ref_count
[
0
]
>
max_refs
||
h
->
ref_count
[
1
]
>
max_refs
)
{
...
@@ -3707,7 +3715,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
...
@@ -3707,7 +3715,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
int
*
ref2frm
=
h
->
ref2frm
[
h
->
slice_num
&
(
MAX_SLICES
-
1
)][
j
];
int
*
ref2frm
=
h
->
ref2frm
[
h
->
slice_num
&
(
MAX_SLICES
-
1
)][
j
];
for
(
i
=
0
;
i
<
16
;
i
++
)
{
for
(
i
=
0
;
i
<
16
;
i
++
)
{
id_list
[
i
]
=
60
;
id_list
[
i
]
=
60
;
if
(
j
<
h
->
list_count
&&
i
<
h
->
ref_count
[
j
]
&&
h
->
ref_list
[
j
][
i
].
f
.
buf
[
0
])
{
if
(
j
<
h
->
list_count
&&
i
<
h
->
ref_count
[
j
]
&&
h
->
ref_list
[
j
][
i
].
f
.
buf
[
0
])
{
int
k
;
int
k
;
AVBuffer
*
buf
=
h
->
ref_list
[
j
][
i
].
f
.
buf
[
0
]
->
buffer
;
AVBuffer
*
buf
=
h
->
ref_list
[
j
][
i
].
f
.
buf
[
0
]
->
buffer
;
for
(
k
=
0
;
k
<
h
->
short_ref_count
;
k
++
)
for
(
k
=
0
;
k
<
h
->
short_ref_count
;
k
++
)
...
@@ -3726,8 +3735,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
...
@@ -3726,8 +3735,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
ref2frm
[
0
]
=
ref2frm
[
0
]
=
ref2frm
[
1
]
=
-
1
;
ref2frm
[
1
]
=
-
1
;
for
(
i
=
0
;
i
<
16
;
i
++
)
for
(
i
=
0
;
i
<
16
;
i
++
)
ref2frm
[
i
+
2
]
=
4
*
id_list
[
i
]
+
ref2frm
[
i
+
2
]
=
4
*
id_list
[
i
]
+
(
h
->
ref_list
[
j
][
i
].
reference
&
3
);
(
h
->
ref_list
[
j
][
i
].
reference
&
3
);
ref2frm
[
18
+
0
]
=
ref2frm
[
18
+
0
]
=
ref2frm
[
18
+
1
]
=
-
1
;
ref2frm
[
18
+
1
]
=
-
1
;
for
(
i
=
16
;
i
<
48
;
i
++
)
for
(
i
=
16
;
i
<
48
;
i
++
)
...
@@ -4330,6 +4338,8 @@ static int execute_decode_slices(H264Context *h, int context_count)
...
@@ -4330,6 +4338,8 @@ static int execute_decode_slices(H264Context *h, int context_count)
return
0
;
return
0
;
}
}
static
const
uint8_t
start_code
[]
=
{
0x00
,
0x00
,
0x01
};
static
int
decode_nal_units
(
H264Context
*
h
,
const
uint8_t
*
buf
,
int
buf_size
,
static
int
decode_nal_units
(
H264Context
*
h
,
const
uint8_t
*
buf
,
int
buf_size
,
int
parse_extradata
)
int
parse_extradata
)
{
{
...
@@ -4514,11 +4524,11 @@ again:
...
@@ -4514,11 +4524,11 @@ again:
return
-
1
;
return
-
1
;
}
else
if
(
CONFIG_H264_VDPAU_DECODER
&&
}
else
if
(
CONFIG_H264_VDPAU_DECODER
&&
h
->
avctx
->
codec
->
capabilities
&
CODEC_CAP_HWACCEL_VDPAU
)
{
h
->
avctx
->
codec
->
capabilities
&
CODEC_CAP_HWACCEL_VDPAU
)
{
static
const
uint8_t
start_code
[]
=
{
ff_vdpau_add_data_chunk
(
h
->
cur_pic_ptr
->
f
.
data
[
0
],
0x00
,
0x00
,
0x01
};
start_code
,
ff_vdpau_add_data_chunk
(
h
->
cur_pic_ptr
->
f
.
data
[
0
],
start_code
,
sizeof
(
start_code
));
sizeof
(
start_code
));
ff_vdpau_add_data_chunk
(
h
->
cur_pic_ptr
->
f
.
data
[
0
],
&
buf
[
buf_index
-
consumed
],
ff_vdpau_add_data_chunk
(
h
->
cur_pic_ptr
->
f
.
data
[
0
],
&
buf
[
buf_index
-
consumed
],
consumed
);
consumed
);
}
else
}
else
context_count
++
;
context_count
++
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment