~ubuntu-branches/ubuntu/wily/libde265/wily

« back to all changes in this revision

Viewing changes to libde265/encoder/sop.cc

  • Committer: Package Import Robot
  • Author(s): Joachim Bauch
  • Date: 2015-07-16 11:07:46 UTC
  • mfrom: (2.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20150716110746-76vsv24j3yux7tnu
Tags: 1.0.2-1
* Imported Upstream version 1.0.2
* Added new files to copyright information.
* Only export decoder API and update symbols for new version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * H.265 video codec.
 
3
 * Copyright (c) 2013-2014 struktur AG, Dirk Farin <farin@struktur.de>
 
4
 *
 
5
 * This file is part of libde265.
 
6
 *
 
7
 * libde265 is free software: you can redistribute it and/or modify
 
8
 * it under the terms of the GNU Lesser General Public License as
 
9
 * published by the Free Software Foundation, either version 3 of
 
10
 * the License, or (at your option) any later version.
 
11
 *
 
12
 * libde265 is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public License
 
18
 * along with libde265.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#include "libde265/encoder/sop.h"
 
22
#include "libde265/encoder/encoder-context.h"
 
23
 
 
24
 
 
25
sop_creator_intra_only::sop_creator_intra_only()
 
26
{
 
27
}
 
28
 
 
29
 
 
30
void sop_creator_intra_only::set_SPS_header_values()
 
31
{
 
32
  mEncCtx->sps.log2_max_pic_order_cnt_lsb = get_num_poc_lsb_bits();
 
33
}
 
34
 
 
35
 
 
36
void sop_creator_intra_only::insert_new_input_image(de265_image* img)
 
37
{
 
38
  img->PicOrderCntVal = get_pic_order_count();
 
39
 
 
40
  reset_poc();
 
41
  int poc = get_pic_order_count();
 
42
 
 
43
  assert(mEncPicBuf);
 
44
  image_data* imgdata = mEncPicBuf->insert_next_image_in_encoding_order(img, get_frame_number());
 
45
 
 
46
  imgdata->set_intra();
 
47
  imgdata->set_NAL_type(NAL_UNIT_IDR_N_LP);
 
48
  imgdata->shdr.slice_type = SLICE_TYPE_I;
 
49
  imgdata->shdr.slice_pic_order_cnt_lsb = get_pic_order_count_lsb();
 
50
 
 
51
  mEncPicBuf->sop_metadata_commit(get_frame_number());
 
52
 
 
53
  advance_frame();
 
54
}
 
55
 
 
56
 
 
57
// ---------------------------------------------------------------------------
 
58
 
 
59
 
 
60
sop_creator_trivial_low_delay::sop_creator_trivial_low_delay()
 
61
{
 
62
}
 
63
 
 
64
 
 
65
void sop_creator_trivial_low_delay::set_SPS_header_values()
 
66
{
 
67
  ref_pic_set rps;
 
68
  rps.DeltaPocS0[0] = -1;
 
69
  rps.UsedByCurrPicS0[0] = true;
 
70
  rps.NumNegativePics = 1;
 
71
  rps.NumPositivePics = 0;
 
72
  rps.compute_derived_values();
 
73
  mEncCtx->sps.ref_pic_sets.push_back(rps);
 
74
  mEncCtx->sps.log2_max_pic_order_cnt_lsb = get_num_poc_lsb_bits();
 
75
}
 
76
 
 
77
 
 
78
void sop_creator_trivial_low_delay::insert_new_input_image(de265_image* img)
 
79
{
 
80
  img->PicOrderCntVal = get_pic_order_count();
 
81
 
 
82
  int frame = get_frame_number();
 
83
 
 
84
  std::vector<int> l0, l1, empty;
 
85
  if (!isIntra(frame)) {
 
86
    l0.push_back(frame-1);
 
87
  }
 
88
 
 
89
  assert(mEncPicBuf);
 
90
  image_data* imgdata = mEncPicBuf->insert_next_image_in_encoding_order(img, get_frame_number());
 
91
 
 
92
  if (isIntra(frame)) {
 
93
    reset_poc();
 
94
    imgdata->set_intra();
 
95
    imgdata->set_NAL_type(NAL_UNIT_IDR_N_LP);
 
96
    imgdata->shdr.slice_type = SLICE_TYPE_I;
 
97
  } else {
 
98
    imgdata->set_references(0, l0,l1, empty,empty);
 
99
    imgdata->set_NAL_type(NAL_UNIT_TRAIL_R);
 
100
    imgdata->shdr.slice_type = SLICE_TYPE_P;
 
101
  }
 
102
  imgdata->shdr.slice_pic_order_cnt_lsb = get_pic_order_count_lsb();
 
103
  mEncPicBuf->sop_metadata_commit(get_frame_number());
 
104
 
 
105
  advance_frame();
 
106
}