Revision bfde0f1b libavcodec/crystalhd.c

View differences:

libavcodec/crystalhd.c
114 114
    struct OpaqueList *next;
115 115
    uint64_t fake_timestamp;
116 116
    uint64_t reordered_opaque;
117
    uint8_t pic_type;
117 118
} OpaqueList;
118 119

  
119 120
typedef struct {
......
209 210
 * OpaqueList functions
210 211
 ****************************************************************************/
211 212

  
212
static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque)
213
static uint64_t opaque_list_push(CHDContext *priv, uint64_t reordered_opaque,
214
                                 uint8_t pic_type)
213 215
{
214 216
    OpaqueList *newNode = av_mallocz(sizeof (OpaqueList));
215 217
    if (!newNode) {
......
226 228
    }
227 229
    priv->tail = newNode;
228 230
    newNode->reordered_opaque = reordered_opaque;
231
    newNode->pic_type = pic_type;
229 232

  
230 233
    return newNode->fake_timestamp;
231 234
}
......
530 533

  
531 534
    CHDContext *priv = avctx->priv_data;
532 535
    int64_t pkt_pts  = AV_NOPTS_VALUE;
536
    uint8_t pic_type = 0;
533 537

  
534 538
    uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) ==
535 539
                           VDEC_FLAG_BOTTOMFIELD;
......
547 551
        OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp);
548 552
        if (node) {
549 553
            pkt_pts = node->reordered_opaque;
554
            pic_type = node->pic_type;
550 555
            av_free(node);
556
        } else {
557
            /*
558
             * We will encounter a situation where a timestamp cannot be
559
             * popped if a second field is being returned. In this case,
560
             * each field has the same timestamp and the first one will
561
             * cause it to be popped. To keep subsequent calculations
562
             * simple, pic_type should be set a FIELD value - doesn't
563
             * matter which, but I chose BOTTOM.
564
             */
565
            pic_type = PICT_BOTTOM_FIELD;
551 566
        }
552 567
        av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n",
553 568
               output->PicInfo.timeStamp);
569
        av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n",
570
               pic_type);
554 571
    }
555 572

  
556 573
    ret = DtsGetDriverStatus(priv->dev, &decoder_status);
......
781 798
             * avoiding mangling so we need to build a mapping to values
782 799
             * we know will not be mangled.
783 800
             */
784
            uint64_t pts = opaque_list_push(priv, avctx->pkt->pts);
801
            uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type);
785 802
            if (!pts) {
786 803
                return AVERROR(ENOMEM);
787 804
            }

Also available in: Unified diff