/* Make local copies of all referenced sample data in the queue.  */
static void sample_queue_retain(HintSampleQueue *queue)
/* Make local copies of all referenced sample data in the queue.  */
static void sample_queue_retain(HintSampleQueue *queue)
{
    int i;
    for (i = 0; i < queue->len; ) {
        HintSample *sample = &queue->samples[i];
        if (!sample->own_data) {
            uint8_t* ptr = av_malloc(sample->size);
            if (!ptr) {
                memmove(queue->samples + i, queue->samples + i + 1,
                        sizeof(HintSample)*(queue->len - i - 1));
                queue->len--;
                continue;
            }
            memcpy(ptr, sample->data, sample->size);
            sample->data = ptr;
            sample->own_data = 1;
        }
        i++;
    }
}