Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFmpeg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libremedia
Tethys
FFmpeg
Commits
f968ef92
Commit
f968ef92
authored
14 years ago
by
Philip Langdale
Browse files
Options
Downloads
Patches
Plain Diff
CrystalHD: Refine heuristic logic.
parent
4ab57cff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libavcodec/crystalhd.c
+28
-29
28 additions, 29 deletions
libavcodec/crystalhd.c
with
28 additions
and
29 deletions
libavcodec/crystalhd.c
+
28
−
29
View file @
f968ef92
...
...
@@ -512,8 +512,7 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
{
BC_STATUS
ret
;
BC_DTS_STATUS
decoder_status
;
uint8_t
confirmed_interlaced
;
uint8_t
ignore_interlaced
;
uint8_t
trust_interlaced
;
uint8_t
interlaced
;
CHDContext
*
priv
=
avctx
->
priv_data
;
...
...
@@ -561,50 +560,50 @@ static inline CopyRet copy_frame(AVCodecContext *avctx,
}
/*
*
If we're expecting a second field, or we know that the next
*
picture has the
s
a
me
number as the current pictu
re
,
the
n we're
*
definitely interlaced.
*
For most content, we can trust the interlaced flag returned
*
by the hardware, but
s
o
me
times we can't. These a
re the
*
conditions under which we can trust the flag:
*
* Note that this test can return false negatives if the hardware
* hasn't decoded the next picture or if there is a corruption in
* the stream. (In either case a 0 will be returned for the next
* picture number)
* 1) It's not h.264 content
* 2) The UNKNOWN_SRC flag is not set
* 3) We know we're expecting a second field
* 4) The hardware reports this picture and the next picture
* have the same picture number.
*
* Note that there can still be interlaced content that will
* fail this check, if the hardware hasn't decoded the next
* picture or if there is a corruption in the stream. (In either
* case a 0 will be returned for the next picture number)
*/
confirmed_interlaced
=
((
decoder_status
.
picNumFlags
&
~
0x40000000
)
==
output
->
PicInfo
.
picture_number
)
||
priv
->
need_second_field
;
trust_interlaced
=
avctx
->
codec
->
id
!=
CODEC_ID_H264
||
!
(
output
->
PicInfo
.
flags
&
VDEC_FLAG_UNKNOWN_SRC
)
||
priv
->
need_second_field
||
(
decoder_status
.
picNumFlags
&
~
0x40000000
)
==
output
->
PicInfo
.
picture_number
;
/*
* If we got a false negative for
confirmed
_interlaced on the first field,
* If we got a false negative for
trust
_interlaced on the first field,
* we will realise our mistake here when we see that the picture number is that
* of the previous picture. We cannot recover the frame and should discard the
* second field to keep the correct number of output frames.
*/
if
(
output
->
PicInfo
.
picture_number
==
priv
->
last_picture
&&
!
priv
->
need_second_field
)
{
av_log
(
avctx
,
AV_LOG_WARNING
,
"Incorrectly guessed progressie frame. Discarding second field
\n
"
);
"Incorrectly guessed progressi
v
e frame. Discarding second field
\n
"
);
/* Returning without providing a picture. */
return
RET_OK
;
}
/*
* Testing has, so far, shown that we can't trust the interlaced flag for
* H.264 content when VDEC_FLAG_UNKNOWN_SRC is set.
*/
ignore_interlaced
=
avctx
->
codec
->
id
==
CODEC_ID_H264
&&
(
output
->
PicInfo
.
flags
&
VDEC_FLAG_UNKNOWN_SRC
)
&&
(
pic_type
==
0
||
pic_type
==
PICT_FRAME
||
!
confirmed_interlaced
);
interlaced
=
(
output
->
PicInfo
.
flags
&
VDEC_FLAG_INTERLACED_SRC
)
&&
(
!
ignore_interlaced
||
confirmed_interlaced
);
if
(
ignore_interlaced
&&
(
decoder_status
.
picNumFlags
&
~
0x40000000
)
==
0
)
{
av_log
(
avctx
,
AV_LOG_WARNING
,
interlaced
=
(
output
->
PicInfo
.
flags
&
VDEC_FLAG_INTERLACED_SRC
)
&&
trust_interlaced
;
if
(
!
trust_interlaced
&&
(
decoder_status
.
picNumFlags
&
~
0x40000000
)
==
0
)
{
av_log
(
avctx
,
AV_LOG_VERBOSE
,
"Next picture number unknown. Assuming progressive frame.
\n
"
);
}
av_log
(
avctx
,
AV_LOG_VERBOSE
,
"Interlaced state: %d |
ignore
_interlaced %d
\n
"
,
interlaced
,
ignore
_interlaced
);
av_log
(
avctx
,
AV_LOG_VERBOSE
,
"Interlaced state: %d |
trust
_interlaced %d
\n
"
,
interlaced
,
trust
_interlaced
);
if
(
priv
->
pic
.
data
[
0
]
&&
!
priv
->
need_second_field
)
avctx
->
release_buffer
(
avctx
,
&
priv
->
pic
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment